import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
+import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData;
import org.tizen.dynamicanalyzer.ui.toolbar.configuration.ConfigurationDialogDataManager;
public class FunctionUsageProfiler extends PageDataManager {
public static final String APPLICATION_KEY = "profiling_app_bin_key";//$NON-NLS-1$
public static final String DEPENDENT_LIB_KEY = "profiling_dependent_lib_key";//$NON-NLS-1$
public static final String UNKNOWN = CommonConstants.EMPTY;
+ public static final int CALLSTACKDATA_MAX = 5000;
private static FunctionUsageProfiler instance = null;
private boolean isSetSamplePeriod = false;
getInstance().getProfileDataMakerByPid(
sample.get(i).getPid())
.makeFunctionUsageProfileData(sampleLog);
- // remove unnecessary callstackdata from memory
- NavigableMap<Long, Integer> seqByTimeMap =
- AnalyzerManager.getCallstackManager()
- .getSeqTimeByTidMap(sampleLog.getTid());
- // find the time of callstackdata which was made
- // right before the current sample time
- // callstackdatas made before that time is needless
- Long lastTime = seqByTimeMap
- .floorKey(sampleLog.getTime());
- if (null != lastTime) {
- SortedMap<Long, Integer> headMap =
- seqByTimeMap.headMap(lastTime);
- Iterator<Map.Entry<Long, Integer>> itr = headMap
- .entrySet().iterator();
- while (itr.hasNext()) {
- Map.Entry<Long, Integer> entry = itr.next();
- AnalyzerManager.getCallstackManager()
- .getCallStackDataBySeqMap()
- .remove(entry.getValue());
- itr.remove();
+ Map<Integer, CallStackData> callstackDataMap = AnalyzerManager.getCallstackManager()
+ .getCallStackDataBySeqMap();
+ if (callstackDataMap.size() > CALLSTACKDATA_MAX) {
+ // remove unnecessary callstackdata from memory
+ NavigableMap<Long, Integer> seqByTimeMap =
+ AnalyzerManager.getCallstackManager()
+ .getSeqTimeByTidMap(sampleLog.getTid());
+ // find the time of callstackdata which was made
+ // right before the current sample time
+ // callstackdatas made before that time is needless
+ Long lastTime = seqByTimeMap
+ .floorKey(sampleLog.getTime());
+ if (null != lastTime) {
+ SortedMap<Long, Integer> headMap =
+ seqByTimeMap.headMap(lastTime);
+ Iterator<Map.Entry<Long, Integer>> itr = headMap
+ .entrySet().iterator();
+ while (itr.hasNext()) {
+ Map.Entry<Long, Integer> entry = itr.next();
+ callstackDataMap.remove(entry.getValue());
+ itr.remove();
+ }
}
}
// save to DB
}
}
} else { // sampling is off, callstackdata is not needed in memory
- AnalyzerManager.getCallstackManager()
- .getCallStackDataBySeqMap().clear();
+ // need to maintain callstackdata until insertion to DB is finished
+ Map<Integer, CallStackData> callstackDataMap = AnalyzerManager.getCallstackManager()
+ .getCallStackDataBySeqMap();
+ if (callstackDataMap.size() > CALLSTACKDATA_MAX) {
+ callstackDataMap.clear();
+ }
}
}
}