Re: Release of NSData causes crash
Re: Release of NSData causes crash
- Subject: Re: Release of NSData causes crash
- From: John Nairn <email@hidden>
- Date: Tue, 2 May 2006 18:06:39 -0700
Yes, it works fine to release back in the method that owns it (which
it what I was doing), but in this case the NSData might be from a
large file (100's of MB) and I have been able to exhaust virtual
memory while reading such a file in a thread. I was attempting to
free some memory in the middle of the reading process (reading is
done in setRecordsFromString) once I was done with it rather than
waiting until the end and control is returned to the owner of gedData.
There might be another problem causing virtual memory limits, but
this was one thing I thought I could try to see if it helped?
On May 2, 2006, at 5:29 PM, Thomas L. Moore wrote:
Have you tried...
NSData *gedData=[[NSData alloc] initWithContentsOfFile:path];
[self setGedcom:gedData];
[gedData release];
- (void)setGedcom:(NSData *)gedcom
{
ged=[[NSString alloc] initWithData:gedcom encoding:encoding];
[self setRecordsFromString:ged];
}
For sanity sake, you should only release an object if you own it.
That is, from the setGedcom method, you don't own gedcom (if you
retained it, then you do own it and would then have to release it),
so you should not send it a release or autorelease statement. Your
calling code, however, does own it and is responsible for releasing
it.
Tom Moore
PaleoTerra
---------------
John Nairn (1-541-737-4265, FAX:1-541-737-3385)
Professor and Richardson Chair
Web Page: http://woodscience.oregonstate.edu/faculty/nairn (under
construction)
FEA/MPM Web Page: http://oregonstate.edu/~nairnj
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden