case HprofHeap.OBJECT: long obj = dumpBuffer.getID(position); byte b = dumpBuffer.get(position); char ch = dumpBuffer.getChar(position); float f = dumpBuffer.getFloat(position); double d = dumpBuffer.getDouble(position); byte bt = dumpBuffer.get(position); short sh = dumpBuffer.getShort(position); int i = dumpBuffer.getInt(position); long lg = dumpBuffer.getLong(position);
protected LongMap initIdMap() throws FileNotFoundException, IOException { return new LongMap(idMapSize,dumpBuffer.getIDSize(),dumpBuffer.getFoffsetSize()); }
Summary(HprofByteBuffer dumpBuffer, long startOffset) { assert dumpBuffer.get(startOffset) == HprofHeap.HEAP_SUMMARY; dumpBuffer.getInt(startOffset + 1); // time dumpBuffer.getInt(startOffset + 1 + 4); // tag length totalLiveBytes = dumpBuffer.getInt(startOffset + 1 + 4 + 4); totalLiveInstances = dumpBuffer.getInt(startOffset + 1 + 4 + 4 + 4); totalAllocatedBytes = dumpBuffer.getLong(startOffset + 1 + 4 + 4 + 4 + 4); totalAllocatedInstances = dumpBuffer.getLong(startOffset + 1 + 4 + 4 + 4 + 4 + 8); time = dumpBuffer.getTime(); }
StackFrame[] getStackFrames() { HprofByteBuffer buf = getHprofBuffer(); int frames = buf.getInt(fileOffset + stackTraceSegment.numberOfFramesOffset); StackFrame[] fr = new StackFrame[frames]; long idOffset = fileOffset + stackTraceSegment.framesListOffset; StackFrameSegment stackFrameSegment = stackTraceSegment.hprofHeap.getStackFrameSegment(); for (int i=0;i<frames;i++,idOffset+=buf.getIDSize()) { long frameID = buf.getID(idOffset); fr[i] = stackFrameSegment.getStackFrameByID(frameID); } return fr; }
int idSize = dumpBuffer.getIDSize(); long[] offset = new long[] { allInstanceDumpBounds.startOffset }; Map<Long, JavaClass> classIdToClassMap = classDumpBounds.getClassIdToClassMap(); classIdOffset = idSize + 4 + 4; } else if (tag == PRIMITIVE_ARRAY_DUMP) { byte type = dumpBuffer.get(start + 1 + idSize + 4 + 4); instanceIdOffset = 1; classDump = classDumpBounds.getPrimitiveArrayClass(type); long instanceId = dumpBuffer.getID(start + instanceIdOffset); instanceEntry = idToOffsetMap.put(instanceId, start); long classId = dumpBuffer.getID(start + 1 + classIdOffset); classDump = (ClassDump) classIdToClassMap.get(new Long(classId));
private String getString(long start) { HprofByteBuffer dumpBuffer = getDumpBuffer(); if (start == -1) { return "<unknown string>"; // NOI18N } int len = dumpBuffer.getInt(start + lengthOffset); byte[] chars = new byte[len - dumpBuffer.getIDSize()]; dumpBuffer.get(start + UTF8CharsOffset, chars); String s = "Error"; // NOI18N try { s = new String(chars, "UTF-8"); // NOI18N } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } return s; }
long getInstanceId() { return heap.dumpBuffer.getID(fileOffset + 1); } }
void findStaticReferencesFor(long instanceId, List<Value> refs) { int i; HprofByteBuffer buffer = getHprofBuffer(); int idSize = buffer.getIDSize(); long fieldOffset = fileOffset + getStaticFieldOffset(); int fields = buffer.getShort(fieldOffset); List<FieldValue> staticFileds = null; HprofHeap heap = getHprof(); fieldOffset += 2; for (i = 0; i < fields; i++) { byte type = buffer.get(fieldOffset + idSize); int size = heap.getValueSize(type); if ((type == HprofHeap.OBJECT) && (instanceId == buffer.getID(fieldOffset + idSize + 1))) { if (staticFileds == null) { staticFileds = getStaticFieldValues(); } refs.add(staticFileds.get(i)); } fieldOffset += (idSize + 1 + size); } if (instanceId == getClassLoaderId()) { if (staticFileds == null) { staticFileds = getStaticFieldValues(); } refs.add(staticFileds.get(fields)); } }
List<Long> refIds = idToOffsetMap.get(instanceId).getReferences(); Iterator<Long> refIdsIt = refIds.iterator(); int idSize = dumpBuffer.getIDSize(); ClassDumpSegment classDumpBounds = getClassDumpSegment(); long[] offset = new long[1]; int size = dumpBuffer.getInt(start + 1 + idSize + 4 + idSize); byte[] fields = new byte[size]; dumpBuffer.get(start + 1 + idSize + 4 + idSize + 4, fields); long classId = dumpBuffer.getID(start + 1 + idSize + 4); ClassDump classDump = classDumpBounds.getClassDumpByID(classId); InstanceDump instance = new InstanceDump(classDump, start); long fieldOffset = start + 1 + dumpBuffer.getIDSize() + 4; int elements = dumpBuffer.getInt(start + 1 + idSize + 4); int i; long position = start + 1 + idSize + 4 + 4 + idSize; if (dumpBuffer.getID(position) == instanceId) { long classId = dumpBuffer.getID(start + 1 + idSize + 4 + 4); ClassDump classDump = classDumpBounds.getClassDumpByID(classId);
void readHeader() throws IOException { long[] offset = new long[1]; String magic = readStringNull(offset, MINIMAL_SIZE); if (DEBUG) { System.out.println("Magic " + magic); // NOI18N } if (magic1.equals(magic)) { version = JAVA_PROFILE_1_0_1; } else if (magic2.equals(magic)) { version = JAVA_PROFILE_1_0_2; } else { if (DEBUG) { System.out.println("Invalid version"); // NOI18N } String errText = ResourceBundle.getBundle("org/netbeans/lib/profiler/heap/Bundle") .getString("HprofByteBuffer_InvalidFormat"); throw new IOException(errText); } idSize = getInt(offset[0]); offset[0] += 4; time = getLong(offset[0]); offset[0] += 8; if (DEBUG) { System.out.println("ID " + idSize); // NOI18N } if (DEBUG) { System.out.println("Date " + new Date(time).toString()); // NOI18N } headerSize = offset[0]; }
int getStaticFiledSize(int staticFieldOffset) { int i; HprofByteBuffer buffer = getHprofBuffer(); int idSize = buffer.getIDSize(); long fieldOffset = fileOffset + staticFieldOffset; int fields = buffer.getShort(fieldOffset); HprofHeap heap = getHprof(); fieldOffset += 2; for (i = 0; i < fields; i++) { byte type = buffer.get(fieldOffset + idSize); int size = heap.getValueSize(type); fieldOffset += (idSize + 1 + size); } return (int) (fieldOffset - staticFieldOffset - fileOffset); }
HprofHeap(File dumpFile, int seg) throws FileNotFoundException, IOException { dumpBuffer = HprofByteBuffer.createHprofByteBuffer(dumpFile); segment = seg; fillTagBounds(dumpBuffer.getHeaderSize()); heapDumpSegment = computeHeapDumpStart(); if (heapDumpSegment != null) { fillHeapTagBounds(); } idToOffsetMap = new LongMap(idMapSize,dumpBuffer.getIDSize(),dumpBuffer.getFoffsetSize()); nearestGCRoot = new NearestGCRoot(this); }
AbstractObjectArrayLazyList(HprofHeap h, HprofByteBuffer buf, int len, long off) { heap = h; dumpBuffer = buf; length = len; offset = off; idSize = dumpBuffer.getIDSize(); }
long getThreadSerialNumber() { return getHprofBuffer().getInt(fileOffset + stackTraceSegment.threadSerialNumberOffset); }