//UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. public virtual Hashtable GetMemoryDump() { lock (this) { lock (objectCache) { if (!opened) { throw new StorageError(StorageError.STORAGE_NOT_OPENED); } int bitmapSize = (int) (SupportClass.URShift(header.root[currIndex].size, (dbAllocationQuantumBits + 5))) + 1; bool existsNotMarkedObjects; long pos; int i, j; // mark greyBitmap = new int[bitmapSize]; blackBitmap = new int[bitmapSize]; int rootOid = header.root[currIndex].rootObject; //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. Hashtable map = new Hashtable(); if (rootOid != 0) { MemoryUsage indexUsage = new MemoryUsage(typeof(Index)); MemoryUsage fieldIndexUsage = new MemoryUsage(typeof(FieldIndex)); MemoryUsage classUsage = new MemoryUsage(typeof(Type)); MarkOid(rootOid); do { existsNotMarkedObjects = false; for (i = 0; i < bitmapSize; i++) { if (greyBitmap[i] != 0) { existsNotMarkedObjects = true; for (j = 0; j < 32; j++) { if ((greyBitmap[i] & (1 << j)) != 0) { pos = (((long) i << 5) + j) << dbAllocationQuantumBits; greyBitmap[i] &= ~ (1 << j); blackBitmap[i] |= 1 << j; int offs = (int) pos & (Page.pageSize - 1); Page pg = pool.GetPage(pos - offs); int typeOid = ObjectHeader.GetType(pg.data, offs); int objSize = ObjectHeader.GetSize(pg.data, offs); int alignedSize = (objSize + dbAllocationQuantum - 1) & ~ (dbAllocationQuantum - 1); if (typeOid != 0) { MarkOid(typeOid); ClassDescriptor desc = FindClassDescriptor(typeOid); if (typeof(Btree).IsAssignableFrom(desc.cls)) { Btree btree = new Btree(pg.data, ObjectHeader.Sizeof + offs); btree.AssignOid(this, 0, false); int nPages = btree.MarkTree(); if (typeof(FieldIndex).IsAssignableFrom(desc.cls)) { fieldIndexUsage.nInstances += 1; fieldIndexUsage.totalSize += (long) nPages * Page.pageSize + objSize; fieldIndexUsage.allocatedSize += (long) nPages * Page.pageSize + alignedSize; } else { indexUsage.nInstances += 1; indexUsage.totalSize += (long) nPages * Page.pageSize + objSize; indexUsage.allocatedSize += (long) nPages * Page.pageSize + alignedSize; } } else { //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. MemoryUsage usage = (MemoryUsage) map[desc.cls]; if (usage == null) { usage = new MemoryUsage(desc.cls); map[desc.cls] = usage; } usage.nInstances += 1; usage.totalSize += objSize; usage.allocatedSize += alignedSize; if (desc.hasReferences) { MarkObject(pool.Get(pos), ObjectHeader.Sizeof, desc); } } } else { classUsage.nInstances += 1; classUsage.totalSize += objSize; classUsage.allocatedSize += alignedSize; } pool.Unfix(pg); } } } } } while (existsNotMarkedObjects); if (indexUsage.nInstances != 0) { map[typeof(Index)] = indexUsage; } if (fieldIndexUsage.nInstances != 0) { map[typeof(FieldIndex)] = fieldIndexUsage; } if (classUsage.nInstances != 0) { map[typeof(Type)] = classUsage; } MemoryUsage system = new MemoryUsage(typeof(Storage)); system.totalSize += header.root[0].indexSize * 8L; system.totalSize += header.root[1].indexSize * 8L; system.totalSize += (long) (header.root[currIndex].bitmapEnd - dbBitmapId) * Page.pageSize; system.totalSize += Page.pageSize; // root page if (header.root[currIndex].bitmapExtent != 0) system.allocatedSize = GetBitmapUsedSpace(dbBitmapId, dbBitmapId + dbBitmapPages) + GetBitmapUsedSpace(header.root[currIndex].bitmapExtent, header.root[currIndex].bitmapExtent + header.root[currIndex].bitmapEnd - dbBitmapId); else system.allocatedSize = GetBitmapUsedSpace(dbBitmapId, header.root[currIndex].bitmapEnd); system.nInstances = header.root[currIndex].indexSize; map[typeof(Storage)] = system; } return map; } } }
private void Mark() { int bitmapSize = (int) (SupportClass.URShift(header.root[currIndex].size, (dbAllocationQuantumBits + 5))) + 1; bool existsNotMarkedObjects; long pos; int i, j; if (listener != null) { listener.GcStarted(); } greyBitmap = new int[bitmapSize]; blackBitmap = new int[bitmapSize]; int rootOid = header.root[currIndex].rootObject; if (rootOid != 0) { MarkOid(rootOid); do { existsNotMarkedObjects = false; for (i = 0; i < bitmapSize; i++) { if (greyBitmap[i] != 0) { existsNotMarkedObjects = true; for (j = 0; j < 32; j++) { if ((greyBitmap[i] & (1 << j)) != 0) { pos = (((long) i << 5) + j) << dbAllocationQuantumBits; greyBitmap[i] &= ~ (1 << j); blackBitmap[i] |= 1 << j; int offs = (int) pos & (Page.pageSize - 1); Page pg = pool.GetPage(pos - offs); int typeOid = ObjectHeader.GetType(pg.data, offs); if (typeOid != 0) { ClassDescriptor desc = FindClassDescriptor(typeOid); if (typeof(Btree).IsAssignableFrom(desc.cls)) { Btree btree = new Btree(pg.data, ObjectHeader.Sizeof + offs); btree.AssignOid(this, 0, false); btree.MarkTree(); } else if (desc.hasReferences) { MarkObject(pool.Get(pos), ObjectHeader.Sizeof, desc); } } pool.Unfix(pg); } } } } } while (existsNotMarkedObjects); } }