memory usage interrogation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38799 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-07-15 14:14:21 +00:00
parent 1ab490d19a
commit 841ddf78e0
17 changed files with 428 additions and 16 deletions

View file

@ -393,4 +393,30 @@ static GC_descr nodeDesc; // Type descriptor for map node.
return GSIMapCountByEnumeratingWithStateObjectsCount
(&map, state, stackbuf, len);
}
- (NSUInteger) sizeInBytes: (NSHashTable*)exclude
{
NSUInteger size = GSPrivateMemorySize(self, exclude);
if (size > 0)
{
NSUInteger count = [self count];
size += GSIMapSize(&map) - sizeof(map);
if (count > 0)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSEnumerator *enumerator = [self keyEnumerator];
NSObject *k;
while ((k = [enumerator nextObject]) != nil)
{
size += [k sizeInBytes: exclude];
}
[pool release];
}
}
return size;
}
@end