Re: Odd crash/method call duplication? - Resolved...
Re: Odd crash/method call duplication? - Resolved...
- Subject: Re: Odd crash/method call duplication? - Resolved...
- From: Nick Morris <email@hidden>
- Date: Sat, 15 Sep 2001 20:18:32 +0100
Hi,
I have finally resolved the problem I discussed earlier in the week. It
turned out to be, as a number of people suggested, due to memory
management. In the last few days I have learnt more about alloc,
release, retain, autorelease and copy than in the preceding three
months! I have also got to know the debugging system quite well,
MallocDebug, and ObjectAlloc.
The problem seemed to be due to my lack of appreciation of what objects
were automatically assigned as autorelease upon creation and the need to
use copy when passing some objects between methods.
Thanks to all those that suggested solutions
Nick
P.S. Next problem will be with NSThread!
Hi,
First post to the list and a real weird one!
I have a really odd crash occurring in my program. The event can't be
easily duplicated.
The program: The program takes a folder of files and processes them.
The files are loaded one at a time, processed and saved before
processing the next file.
Symptoms: Everything was running fine and I was checking for memory
leaks which I thought were occurring as the program tended to slow down
as it ran. I located some of the problems and thought I had dealt with
them. I also did some optimization. I regularly compiled and ran the
program . However, suddenly the program started to crash and yet there
did not appear to be anything wrong with the added code.
The crashes: The crashes could occur at any point in the processing
method once the button was clicked to start the run. The crash could
occur in the first few lines of the method, in the middle of the method,
or at the end of the method. Crashes ranged from miss-matched objects
and memory allocation problems. Sometime the program would successfully
parse all the files and then just crash as it exited the method.
Closer examination of the code using the debug function did not reveal
anything obvious. After a lot of work I discovered that in debug I was
seeing the following
# Frame
0 - [fileController setParser]
setParser calls the method that has the problem and stops at a
breakpoint on the first {. This results in:
# Frame
0 - [fileController setParser]
1 - [fileController parseFile:]
As soon as the first { is passed the reading changes to:
# Frame
0 - [fileController parseFile:]
1 - [fileController parseFile:]
Why does [fileController setParser] get replaced with [fileController
parseFile:]?
I assume this is causing the problem?
If I comment out the whole contents of the method and just put in some
code such as:
NSString *testString = @"this is a test";
NSLog(@"The method fired and %@", testString);
I get:
# Frame
0 - [fileController setParser]
1 - [fileController parseFile:]
And the method fires and exits OK.
I have found that if I comment out sections of the code things also run
fine (except the files don't get fully processed). It seems that it is
the size/length of the method (which is quite long, around 350 lines of
code) is the problem. Could it be?
Any thoughts, comments will be greatly appreciated!
Thanks
Nick