FileDocCategorySizeDatePackage
DdmHandleHeap.javaAPI DocAndroid 1.5 API6114Wed May 06 22:41:54 BST 2009android.ddm

DdmHandleHeap

public class DdmHandleHeap extends org.apache.harmony.dalvik.ddmc.ChunkHandler
Handle thread-related traffic.

Fields Summary
public static final int
CHUNK_HPIF
public static final int
CHUNK_HPSG
public static final int
CHUNK_NHSG
public static final int
CHUNK_HPGC
public static final int
CHUNK_REAE
public static final int
CHUNK_REAQ
public static final int
CHUNK_REAL
private static DdmHandleHeap
mInstance
Constructors Summary
private DdmHandleHeap()



    /* singleton, do not instantiate */
      
Methods Summary
public voidconnected()
Called when the DDM server connects. The handler is allowed to send messages to the server.

public voiddisconnected()
Called when the DDM server disconnects. Can be used to disable periodic transmissions or clean up saved state.

public org.apache.harmony.dalvik.ddmc.ChunkhandleChunk(org.apache.harmony.dalvik.ddmc.Chunk request)
Handle a chunk of data.

        if (Config.LOGV)
            Log.v("ddm-heap", "Handling " + name(request.type) + " chunk");
        int type = request.type;

        if (type == CHUNK_HPIF) {
            return handleHPIF(request);
        } else if (type == CHUNK_HPSG) {
            return handleHPSGNHSG(request, false);
        } else if (type == CHUNK_NHSG) {
            return handleHPSGNHSG(request, true);
        } else if (type == CHUNK_HPGC) {
            return handleHPGC(request);
        } else if (type == CHUNK_REAE) {
            return handleREAE(request);
        } else if (type == CHUNK_REAQ) {
            return handleREAQ(request);
        } else if (type == CHUNK_REAL) {
            return handleREAL(request);
        } else {
            throw new RuntimeException("Unknown packet "
                + ChunkHandler.name(type));
        }
    
private org.apache.harmony.dalvik.ddmc.ChunkhandleHPGC(org.apache.harmony.dalvik.ddmc.Chunk request)

        //ByteBuffer in = wrapChunk(request);

        if (Config.LOGD)
            Log.d("ddm-heap", "Heap GC request");
        System.gc();

        return null;        // empty response
    
private org.apache.harmony.dalvik.ddmc.ChunkhandleHPIF(org.apache.harmony.dalvik.ddmc.Chunk request)

        ByteBuffer in = wrapChunk(request);

        int when = in.get();
        if (Config.LOGV)
            Log.v("ddm-heap", "Heap segment enable: when=" + when);

        boolean ok = DdmVmInternal.heapInfoNotify(when);
        if (!ok) {
            return createFailChunk(1, "Unsupported HPIF what");
        } else {
            return null;        // empty response
        }
    
private org.apache.harmony.dalvik.ddmc.ChunkhandleHPSGNHSG(org.apache.harmony.dalvik.ddmc.Chunk request, boolean isNative)

        ByteBuffer in = wrapChunk(request);

        int when = in.get();
        int what = in.get();
        if (Config.LOGV)
            Log.v("ddm-heap", "Heap segment enable: when=" + when
                + ", what=" + what + ", isNative=" + isNative);

        boolean ok = DdmVmInternal.heapSegmentNotify(when, what, isNative);
        if (!ok) {
            return createFailChunk(1, "Unsupported HPSG what/when");
        } else {
            // TODO: if "when" is non-zero and we want to see a dump
            //       right away, initiate a GC.
            return null;        // empty response
        }
    
private org.apache.harmony.dalvik.ddmc.ChunkhandleREAE(org.apache.harmony.dalvik.ddmc.Chunk request)

        ByteBuffer in = wrapChunk(request);
        boolean enable;

        enable = (in.get() != 0);

        if (Config.LOGD)
            Log.d("ddm-heap", "Recent allocation enable request: " + enable);

        DdmVmInternal.enableRecentAllocations(enable);

        return null;        // empty response
    
private org.apache.harmony.dalvik.ddmc.ChunkhandleREAL(org.apache.harmony.dalvik.ddmc.Chunk request)

        //ByteBuffer in = wrapChunk(request);

        if (Config.LOGD)
            Log.d("ddm-heap", "Recent allocations request");

        /* generate the reply in a ready-to-go format */
        byte[] reply = DdmVmInternal.getRecentAllocations();
        return new Chunk(CHUNK_REAL, reply, 0, reply.length);
    
private org.apache.harmony.dalvik.ddmc.ChunkhandleREAQ(org.apache.harmony.dalvik.ddmc.Chunk request)

        //ByteBuffer in = wrapChunk(request);

        byte[] reply = new byte[1];
        reply[0] = DdmVmInternal.getRecentAllocationStatus() ? (byte)1 :(byte)0;
        return new Chunk(CHUNK_REAQ, reply, 0, reply.length);
    
public static voidregister()
Register for the messages we're interested in.

        DdmServer.registerHandler(CHUNK_HPIF, mInstance);
        DdmServer.registerHandler(CHUNK_HPSG, mInstance);
        DdmServer.registerHandler(CHUNK_NHSG, mInstance);
        DdmServer.registerHandler(CHUNK_HPGC, mInstance);
        DdmServer.registerHandler(CHUNK_REAE, mInstance);
        DdmServer.registerHandler(CHUNK_REAQ, mInstance);
        DdmServer.registerHandler(CHUNK_REAL, mInstance);