Re: subpathsAtPath and memory usage
Re: subpathsAtPath and memory usage
- Subject: Re: subpathsAtPath and memory usage
- From: "John C. Randolph" <email@hidden>
- Date: Thu, 23 Aug 2007 01:31:58 -0700
On Aug 22, 2007, at 1:19 PM, email@hidden wrote:
Hi,
I have an NSFileManager / memory usage question. I have searched the
archives, the Cocoadev wiki and other sites but I can't seem to find
the answer.
In my app I'm using NSFileManager's subpathsAtPath call and this
works fine. However, when working with large directory structures
(e.g. my Home folder), this takes a lot of memory. This is probably
normal, but what puzzles me is that the memory is retained even when
the method has reached the end and all objects should have been
released. For example, for my Home folder the method below builds up
memory usage from about 30 MB to 650 MB. Even long after the method
below is completed, the memory usage remains at 650 MB.
This is what I'm doing:
- (IBAction)testMemory:(id)sender;
{
// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *children = [[NSFileManager defaultManager]
subpathsAtPath:@"/Users/myUserName/"];
// [pool release];
NSLog(@"Done!");
}
As can be seen from the code above, I even tried to create and
release my own NSAutoreleasePool but this has no effect. The memory
for my app builds up to 650 MB after this call and remains at that
level, long after everything should have been (auto)released. I
tried the same thing with the enumeratorAtPath approach but this has
the same effect.
Is there anything that can be done to avoid this. I guess the
problem might be that [NSFileManager defaultManager] does not
release its memory and since the object is a singleton, it stays
alive as long as my app lives.
Any suggestions on how to reclaim the memory that has been consumed
by this call would be much appreciated!
Not sure what else is retaining those paths, but normally I'd use an
NSDirectoryEnumerator instead of trying to make up an array of all the
paths like this.
-jcr
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden