Search in sources :

Example 6 with ClassObj

use of com.android.tools.perflib.heap.ClassObj in project android_frameworks_base by AOSPA.

the class Hprof method analyzeHprof.

/**
     * Return a map of class names to class-loader names derived from the hprof dump.
     *
     * @param hprofLocalFile
     */
public static Map<String, String> analyzeHprof(File hprofLocalFile) throws Exception {
    Snapshot snapshot = Snapshot.createSnapshot(new MemoryMappedFileBuffer(hprofLocalFile));
    Map<String, Set<ClassObj>> classes = Queries.classes(snapshot, null);
    Map<String, String> retValue = new HashMap<String, String>();
    for (Map.Entry<String, Set<ClassObj>> e : classes.entrySet()) {
        for (ClassObj c : e.getValue()) {
            String cl = c.getClassLoader() == null ? null : c.getClassLoader().toString();
            String cName = c.getClassName();
            int aDepth = 0;
            while (cName.endsWith("[]")) {
                cName = cName.substring(0, cName.length() - 2);
                aDepth++;
            }
            String newName = transformPrimitiveClass(cName);
            if (aDepth > 0) {
                // Need to use kind-a descriptor syntax. If it was transformed, it is primitive.
                if (newName.equals(cName)) {
                    newName = "L" + newName + ";";
                }
                for (int i = 0; i < aDepth; i++) {
                    newName = "[" + newName;
                }
            }
            retValue.put(newName, cl);
        }
    }
    // Free up memory.
    snapshot.dispose();
    return retValue;
}
Also used : MemoryMappedFileBuffer(com.android.tools.perflib.captures.MemoryMappedFileBuffer) ClassObj(com.android.tools.perflib.heap.ClassObj) Snapshot(com.android.tools.perflib.heap.Snapshot) Set(java.util.Set) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with ClassObj

use of com.android.tools.perflib.heap.ClassObj in project android_frameworks_base by ResurrectionRemix.

the class Hprof method analyzeHprof.

/**
     * Return a map of class names to class-loader names derived from the hprof dump.
     *
     * @param hprofLocalFile
     */
public static Map<String, String> analyzeHprof(File hprofLocalFile) throws Exception {
    Snapshot snapshot = Snapshot.createSnapshot(new MemoryMappedFileBuffer(hprofLocalFile));
    Map<String, Set<ClassObj>> classes = Queries.classes(snapshot, null);
    Map<String, String> retValue = new HashMap<String, String>();
    for (Map.Entry<String, Set<ClassObj>> e : classes.entrySet()) {
        for (ClassObj c : e.getValue()) {
            String cl = c.getClassLoader() == null ? null : c.getClassLoader().toString();
            String cName = c.getClassName();
            int aDepth = 0;
            while (cName.endsWith("[]")) {
                cName = cName.substring(0, cName.length() - 2);
                aDepth++;
            }
            String newName = transformPrimitiveClass(cName);
            if (aDepth > 0) {
                // Need to use kind-a descriptor syntax. If it was transformed, it is primitive.
                if (newName.equals(cName)) {
                    newName = "L" + newName + ";";
                }
                for (int i = 0; i < aDepth; i++) {
                    newName = "[" + newName;
                }
            }
            retValue.put(newName, cl);
        }
    }
    // Free up memory.
    snapshot.dispose();
    return retValue;
}
Also used : MemoryMappedFileBuffer(com.android.tools.perflib.captures.MemoryMappedFileBuffer) ClassObj(com.android.tools.perflib.heap.ClassObj) Snapshot(com.android.tools.perflib.heap.Snapshot) Set(java.util.Set) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with ClassObj

use of com.android.tools.perflib.heap.ClassObj in project android_frameworks_base by crdroidandroid.

the class Hprof method analyzeHprof.

/**
     * Return a map of class names to class-loader names derived from the hprof dump.
     *
     * @param hprofLocalFile
     */
public static Map<String, String> analyzeHprof(File hprofLocalFile) throws Exception {
    Snapshot snapshot = Snapshot.createSnapshot(new MemoryMappedFileBuffer(hprofLocalFile));
    Map<String, Set<ClassObj>> classes = Queries.classes(snapshot, null);
    Map<String, String> retValue = new HashMap<String, String>();
    for (Map.Entry<String, Set<ClassObj>> e : classes.entrySet()) {
        for (ClassObj c : e.getValue()) {
            String cl = c.getClassLoader() == null ? null : c.getClassLoader().toString();
            String cName = c.getClassName();
            int aDepth = 0;
            while (cName.endsWith("[]")) {
                cName = cName.substring(0, cName.length() - 2);
                aDepth++;
            }
            String newName = transformPrimitiveClass(cName);
            if (aDepth > 0) {
                // Need to use kind-a descriptor syntax. If it was transformed, it is primitive.
                if (newName.equals(cName)) {
                    newName = "L" + newName + ";";
                }
                for (int i = 0; i < aDepth; i++) {
                    newName = "[" + newName;
                }
            }
            retValue.put(newName, cl);
        }
    }
    // Free up memory.
    snapshot.dispose();
    return retValue;
}
Also used : MemoryMappedFileBuffer(com.android.tools.perflib.captures.MemoryMappedFileBuffer) ClassObj(com.android.tools.perflib.heap.ClassObj) Snapshot(com.android.tools.perflib.heap.Snapshot) Set(java.util.Set) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ClassObj (com.android.tools.perflib.heap.ClassObj)8 MemoryMappedFileBuffer (com.android.tools.perflib.captures.MemoryMappedFileBuffer)5 Snapshot (com.android.tools.perflib.heap.Snapshot)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Set (java.util.Set)5 TreePath (javax.swing.tree.TreePath)2 HeapClassObjNode (com.android.tools.idea.editors.hprof.views.nodedata.HeapClassObjNode)1 HeapNode (com.android.tools.idea.editors.hprof.views.nodedata.HeapNode)1 Heap (com.android.tools.perflib.heap.Heap)1 IOException (java.io.IOException)1 TreeNode (javax.swing.tree.TreeNode)1 Nullable (org.jetbrains.annotations.Nullable)1