mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Improved memory usage reporting mechanisms
This commit is contained in:
parent
2ca4f74af5
commit
dd36855923
21 changed files with 404 additions and 230 deletions
|
@ -73,19 +73,16 @@ static Class GSInlineArrayClass;
|
|||
|
||||
@implementation GSArray
|
||||
|
||||
+ (NSUInteger) contentSizeOf: (NSObject*)obj
|
||||
declaredIn: (Class)cls
|
||||
excluding: (NSHashTable*)exclude
|
||||
- (NSUInteger) sizeOfContentExcluding: (NSHashTable*)exclude
|
||||
{
|
||||
GSArray *a = (GSArray*)obj;
|
||||
NSUInteger size = a->_count * sizeof(id);
|
||||
NSUInteger index = a->_count;
|
||||
NSUInteger size = _count * sizeof(id);
|
||||
NSUInteger index = _count;
|
||||
|
||||
while (index-- > 0)
|
||||
{
|
||||
size += [a->_contents_array[index] sizeInBytesExcluding: exclude];
|
||||
size += [_contents_array[index] sizeInBytesExcluding: exclude];
|
||||
}
|
||||
return size;
|
||||
return size + [super sizeOfContentExcluding: exclude];
|
||||
}
|
||||
|
||||
- (void) _raiseRangeExceptionWithIndex: (NSUInteger)index from: (SEL)sel
|
||||
|
@ -436,19 +433,11 @@ static Class GSInlineArrayClass;
|
|||
|
||||
@implementation GSMutableArray
|
||||
|
||||
+ (NSUInteger) contentSizeOf: (NSObject*)obj
|
||||
declaredIn: (Class)cls
|
||||
excluding: (NSHashTable*)exclude
|
||||
- (NSUInteger) sizeOfContentExcluding: (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;
|
||||
/* Can't safely calculate for mutable object; just buffer size
|
||||
*/
|
||||
return _capacity * sizeof(void*);
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue