HAHA (Headless Android Heap Analyzer)

repository·master·Indexed 23 days ago

https://github.com/square/haha

A Java library for automating the analysis of Android heap dumps by providing a headless way to parse and query HPROF files. Note: This project is deprecated; users are encouraged to use the heap dump parser maintained by LeakCanary.

Tokens
420
Snippets
2
Records
3
Agent score
31%

What's inside HAHA

  1. Deprecation Notice: Use LeakCanary's heap dump parser instead

    master

    This repository is DEPRECATED. HAHA was originally created to provide a heap dump parser for LeakCanary by repackaging existing parsers.

    LeakCanary now maintains its own dedicated heap dump parser. If you are looking for the current implementation, use the following Maven dependency:

    com.squareup.leakcanary:leakcanary-haha:2.0-alpha-1

  2. Analyze an Android heap dump with HAHA

    master

    To analyze an Android heap dump, first ensure you have dumped the heap using Android's Debug.dumpHprofData. Then, use HAHA to create a MemoryMappedFileBuffer from the file, create a Snapshot, and query the heap for specific objects.

    Note: The MemoryMappedFileBuffer is used to efficiently map the heap dump file into memory for parsing.

    File heapDumpFile = ...
    Debug.dumpHprofData(heapDumpFile.getAbsolutePath());
    
    // After dumping, use HAHA to parse and analyze
    DataBuffer buffer = new MemoryMappedFileBuffer(heapDumpFile);
    Snapshot snapshot = Snapshot.createSnapshot(buffer);
    
    // Example: Find a specific class in the heap
    ClassObj someClass = snapshot.findClass("com.example.SomeClass");