本文整理汇总了C++中SegManager::getSegments方法的典型用法代码示例。如果您正苦于以下问题:C++ SegManager::getSegments方法的具体用法?C++ SegManager::getSegments怎么用?C++ SegManager::getSegments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SegManager
的用法示例。
在下文中一共展示了SegManager::getSegments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run_gc
void run_gc(EngineState *s) {
SegManager *segMan = s->_segMan;
// Some debug stuff
debugC(kDebugLevelGC, "[GC] Running...");
#ifdef GC_DEBUG_CODE
const char *segnames[SEG_TYPE_MAX + 1];
int segcount[SEG_TYPE_MAX + 1];
memset(segnames, 0, sizeof(segnames));
memset(segcount, 0, sizeof(segcount));
#endif
// Compute the set of all segments references currently in use.
AddrSet *activeRefs = findAllActiveReferences(s);
// Iterate over all segments, and check for each whether it
// contains stuff that can be collected.
const Common::Array<SegmentObj *> &heap = segMan->getSegments();
for (uint seg = 1; seg < heap.size(); seg++) {
SegmentObj *mobj = heap[seg];
if (mobj != NULL) {
#ifdef GC_DEBUG_CODE
const SegmentType type = mobj->getType();
segnames[type] = segmentTypeNames[type];
#endif
// Get a list of all deallocatable objects in this segment,
// then free any which are not referenced from somewhere.
const Common::Array<reg_t> tmp = mobj->listAllDeallocatable(seg);
for (Common::Array<reg_t>::const_iterator it = tmp.begin(); it != tmp.end(); ++it) {
const reg_t addr = *it;
if (!activeRefs->contains(addr)) {
// Not found -> we can free it
mobj->freeAtAddress(segMan, addr);
debugC(kDebugLevelGC, "[GC] Deallocating %04x:%04x", PRINT_REG(addr));
#ifdef GC_DEBUG_CODE
segcount[type]++;
#endif
}
}
}
}
delete activeRefs;
#ifdef GC_DEBUG_CODE
// Output debug summary of garbage collection
debugC(kDebugLevelGC, "[GC] Summary:");
for (int i = 0; i <= SEG_TYPE_MAX; i++)
if (segcount[i])
debugC(kDebugLevelGC, "\t%d\t* %s", segcount[i], segnames[i]);
#endif
}