Search in sources :

Example 1 with Snapshot

use of com.android.tools.perflib.heap.Snapshot in project android_frameworks_base by DirtyUnicorns.

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 2 with Snapshot

use of com.android.tools.perflib.heap.Snapshot in project platform_frameworks_base by android.

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 3 with Snapshot

use of com.android.tools.perflib.heap.Snapshot 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 4 with Snapshot

use of com.android.tools.perflib.heap.Snapshot 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 5 with Snapshot

use of com.android.tools.perflib.heap.Snapshot 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

MemoryMappedFileBuffer (com.android.tools.perflib.captures.MemoryMappedFileBuffer)5 ClassObj (com.android.tools.perflib.heap.ClassObj)5 Snapshot (com.android.tools.perflib.heap.Snapshot)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Set (java.util.Set)5