mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
improve reportingn of memory usage
This commit is contained in:
parent
42b404c586
commit
3f7d54a33f
18 changed files with 395 additions and 267 deletions
|
@ -73,6 +73,21 @@ static Class GSInlineArrayClass;
|
|||
|
||||
@implementation GSArray
|
||||
|
||||
+ (NSUInteger) contentSizeOf: (NSObject*)obj
|
||||
declaredIn: (Class)cls
|
||||
excluding: (NSHashTable*)exclude
|
||||
{
|
||||
GSArray *a = (GSArray*)obj;
|
||||
NSUInteger size = a->_count * sizeof(id);
|
||||
NSUInteger index = a->_count;
|
||||
|
||||
while (index-- > 0)
|
||||
{
|
||||
size += [a->_contents_array[index] sizeInBytesExcluding: exclude];
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
- (void) _raiseRangeExceptionWithIndex: (NSUInteger)index from: (SEL)sel
|
||||
{
|
||||
NSDictionary *info;
|
||||
|
@ -421,6 +436,21 @@ static Class GSInlineArrayClass;
|
|||
|
||||
@implementation GSMutableArray
|
||||
|
||||
+ (NSUInteger) contentSizeOf: (NSObject*)obj
|
||||
declaredIn: (Class)cls
|
||||
excluding: (NSHashTable*)exclude
|
||||
{
|
||||
GSMutableArray *a = (GSMutableArray*)obj;
|
||||
NSUInteger size = a->_capacity * sizeof(id);
|
||||
NSUInteger index = a->_count;
|
||||
|
||||
while (index-- > 0)
|
||||
{
|
||||
size += [a->_contents_array[index] sizeInBytesExcluding: exclude];
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSMutableArray class])
|
||||
|
@ -938,22 +968,6 @@ static Class GSInlineArrayClass;
|
|||
return count;
|
||||
}
|
||||
|
||||
- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
|
||||
{
|
||||
NSUInteger size = GSPrivateMemorySize(self, exclude);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
NSUInteger count = _count;
|
||||
|
||||
size += _capacity*sizeof(void*);
|
||||
while (count-- > 0)
|
||||
{
|
||||
size += [_contents_array[count] sizeInBytesExcluding: exclude];
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue