Upgrade to Pro — share decks privately, control downloads, hide ads and more …

メモリリークを気軽に確認するLeakCheckerの話

800912a73ce4e879003b6c89cf80cfeb?s=47 yagi
April 09, 2014

 メモリリークを気軽に確認するLeakCheckerの話

メモリリークのチェックって大変だなぁと思って

800912a73ce4e879003b6c89cf80cfeb?s=128

yagi

April 09, 2014
Tweet

Transcript

  1. ϝϞϦϦʔΫΛؾܰʹ֬ ೝ͢Δ-FBL$IFDLFSͷ࿩ QPUBUPUJQT 5PTIJIJSP:BHJ

  2. "CPVUNF 5XJUUFS!TZTZBHJ #MPHIUUQTZTZBHJDPN ! ! "OESPJE&OHJOFFSBU

  3. ϝϞϦϦʔΫͷνΣο Ϋͬͯେมͩͳ͊

  4. طଘπʔϧେม w 5SBDFWJFXͱ͔.FNPSZ"OBMZ[FS͸ͳΜ͔ΊΜͲ ͍͘͞

  5. ΋ͬͱΧδϡΞϧʹ͍ͨ͠

  6. ΋ͬͱΧδϡΞϧʹ͠Α͏

  7. -FBL$IFDLFS https://github.com/sys1yagi/leak-checker

  8. .PEVMFT LeakCheker MemoryUsage ϦʔΫΛνΣοΫ͢Δਓ ΞϓϦͷϝϞϦ࢖༻ঢ়گΛڭ͑ͯ͘ΕΔਓ W ILogger ϩάΛు͘ਓ

  9. -FBL$IFDLFS LeakCheker MemoryUsage ILogger App add object start monitoring output

    output
  10. %&.0

  11. 4FUVQ apply plugin: 'android' ! repositories { mavenCentral() maven {

    url 'https://raw.github.com/sys1yagi/leak-checker/master/repository' } } dependencies { compile 'com.sys1yagi:leak-checker:0.0.1' } 3FGFSFODF3FQPTJUPSZ %FQFOEFODJFT
  12. .FNPSZ6TBHF @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MemoryUsage.startPrintMemoryUsage(); }

    ! @Override public void onDestroy() { super.onDestroy(); MemoryUsage.stopPrintMemoryUsage(); } TUBSUTUPQ
  13. -FBL$IFLFS LeakChecker.addLeakChecker(bitmap) LeakChecker.dump() SFHJTUFSPCKFDUT EVNQUIFPCKFDUPGPONFNPSZ

  14. $VTUPN-PHHFS public class TextViewMonitorLogger implements ILogger { private TextView target;

    ! public TextViewMonitorLogger(TextView target) { this.target = target; } ! @Override public void print(String tag, String message) { target.setText(message); } } LeakChecker.setLogger(logger); MemoryUsage.setLogger(logger); JNQMFNFOU*-PHHFS VTFDVTUPNMPHHFS
  15. ·ͱΊ w .FNPSZ6TBHF w ΞϓϦͷϝϞϦ࢖༻ঢ়گΛऔΕΔ w -FBL$IFDLFS w ΦϒδΣΫτΛ؂ࢹͰ͖Δ w

    EVNQͯ͠ϦʔΫͯ͠Δ͔νΣοΫʂʂ w *-PHHFS w *-PHHFSΛ࣮૷͢Ε͹Ͳ͜ʹͰ΋ग़ͤΔ
  16. ͋Γ͕ͱ͏͍͟͝·ͨ͠

  17. 8FBSFIJSJOH IUUQTJOGPDPPLQBEDPNKPCTQPTJUJPOJPTBOESPJEBQQFOHJOFFS