org.netbeans.lib.profiler.heap.TreeObject Maven / Gradle / Ivy
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.lib.profiler.heap;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
*
* @author Tomas Hurka
*/
class TreeObject {
//~ Static fields/initializers -----------------------------------------------------------------------------------------------
private static final int BUFFER_SIZE = (64 * 1024) / 8;
//~ Instance fields ----------------------------------------------------------------------------------------------------------
private HprofHeap heap;
private LongBuffer readBuffer;
private LongBuffer writeBuffer;
private Set unique;
//private long nextLevelSize;
//~ Constructors -------------------------------------------------------------------------------------------------------------
TreeObject(HprofHeap h, LongBuffer leaves) {
heap = h;
writeBuffer = leaves;
}
//~ Methods ------------------------------------------------------------------------------------------------------------------
synchronized void computeTrees() {
boolean changed;
try {
createBuffers();
do {
switchBuffers();
changed = computeOneLevel();
//Systems.debug("Tree obj. "+heap.idToOffsetMap.treeObj);
//if (changed) Systems.debug("Next level "+nextLevelSize);
} while (changed);
} catch (IOException ex) {
Systems.printStackTrace(ex);
}
deleteBuffers();
//Systems.debug("Done!");
}
private boolean computeOneLevel() throws IOException {
//nextLevelSize = 0;
boolean changed = false;
int idSize = heap.dumpBuffer.getIDSize();
for (;;) {
long instanceId = readLong();
Instance instance;
List fieldValues;
Iterator valuesIt;
long retainedSize = 0;
if (instanceId == 0) { // end of level
break;
}
instance = heap.getInstanceByID(instanceId);
if (instance instanceof ObjectArrayInstance) {
ObjectArrayDump array = (ObjectArrayDump) instance;
int arrSize = array.getLength();
long offset = array.getOffset();
long size = 0;
LongSet refs = new LongSet();
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy