improve reportingn of memory usage

This commit is contained in:
Richard Frith-Macdonald 2019-06-11 14:07:10 +01:00
parent 42b404c586
commit 3f7d54a33f
18 changed files with 395 additions and 267 deletions

View file

@ -1170,6 +1170,28 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
@implementation NSConcreteMapTable
+ (NSUInteger) contentSizeOf: (NSObject*)obj
declaredIn: (Class)cls
excluding: (NSHashTable*)exclude
{
GSIMapTable map = (GSIMapTable)obj;
NSUInteger size = GSIMapSize(map) - sizeof(GSIMapTable);
/* If we knew that this table held objects, we could return their size...
GSIMapEnumerator_t enumerator = GSIMapEnumeratorForMap(map);
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
while (node != 0)
{
size += [node->key.obj sizeInBytesExcluding: exclude];
size += [node->value.obj sizeInBytesExcluding: exclude];
node = GSIMapEnumeratorNextNode(&enumerator);
}
GSIMapEndEnumerator(&enumerator);
*/
return size;
}
+ (void) initialize
{
if (concreteClass == Nil)
@ -1400,29 +1422,6 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
return [p autorelease];
}
- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
{
NSUInteger size = [super sizeInBytesExcluding: exclude];
if (size > 0)
{
/* If we knew that this table held objects, we could return their size...
*
* GSIMapEnumerator_t enumerator = GSIMapEnumeratorForMap(self);
* GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
*
* while (node != 0)
* {
* node = GSIMapEnumeratorNextNode(&enumerator);
* size += [node->key.obj sizeInBytesExcluding: exclude];
* size += [node->value.obj sizeInBytesExcluding: exclude];
* }
* GSIMapEndEnumerator(&enumerator);
*/
size += GSIMapSize(self) - instanceSize;
}
return size;
}
@end
@implementation NSConcreteMapTableKeyEnumerator