08-11-2010, 08:30 PM
#1 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Navigation Controller problems
Hi, I have an app that has alot of view and when I navigate to a view with an image on it the memory goes from 2mbs used to 15mbs used and then return to the previous view the memory stays at 15. I have released the images on the view and the memory still doesnt release. Please help.
08-11-2010, 09:14 PM
#2 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
If you simulate a memory warning, does it go back down?
08-11-2010, 09:28 PM
#3 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
If you simulate a memory warning, does it go back down?
No it doesnt
08-11-2010, 09:29 PM
#4 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
Post some code then.
08-11-2010, 09:33 PM
#5 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Im new a development and dont know what to post sorry.
08-11-2010, 09:34 PM
#6 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
Well, you think the problem is related to images, then post code related to images. Where you create them, how you use them, how you destroy them, etc.
08-11-2010, 09:38 PM
#7 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
Well, you think the problem is related to images, then post code related to images. Where you create them, how you use them, how you destroy them, etc.
in my .h
@property(nonatomic,retain)IBOutlet UIImageView *fast1;
@property(nonatomic,retain)IBOutlet UIImageView *fast2;
in the .m
- (void)viewDidDisappear
BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"release");
[fast1 removeFromSuperview];
[fast2 removeFromSuperview];
[texts removeFromSuperview];
}
- (void)dealloc {
NSLog(@"Releasing");
[fast1 release];
[fast2 release];
[texts release];
[super dealloc];
}
i just add them in IB and attach the outlet so I can remove them and release the mem.
08-11-2010, 09:40 PM
#8 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
Do you see the "Releasing" log?
Removing from superview isn't necessary, btw. If that is the only reason you have the outlets, don't bother.
08-11-2010, 09:42 PM
#9 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
Do you see the "Releasing" log?
Removing from superview isn't necessary, btw. If that is the only reason you have the outlets, don't bother.
In the log I see that they are releasing. So I can still release them if I dont have and outlet for them?
08-11-2010, 09:46 PM
#10 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
You don't need to. The view will release the imageviews - which will in turn release the images - when the view controller goes away.
I'm not seeing any errors in the code here, so as long as you are certain that the view controller is dying, I wouldn't worry about it. You're probably just seeing the image cache.
08-11-2010, 09:48 PM
#11 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
You don't need to. The view will release the imageviews - which will in turn release the images - when the view controller goes away.
I'm not seeing any errors in the code here, so as long as you are certain that the view controller is dying, I wouldn't worry about it. You're probably just seeing the image cache.
How do I tell if the view controller is dying? When I navigate back from the view with the images the memory used goes up.
08-11-2010, 09:49 PM
#12 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
If you are seeing that log in the dealloc method, then the view controller is dying.
08-11-2010, 09:51 PM
#13 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
If you are seeing that log in the dealloc method, then the view controller is dying.
ok thanks
08-11-2010, 09:52 PM
#14 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
If you go forward and back a bunch of times, does the memory keep growing, or does it stay around 15?
08-11-2010, 09:55 PM
#15 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
I just ran it through again and the log showed a level 1 memory warning.
08-11-2010, 09:56 PM
#16 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
If you go forward and back a bunch of times, does the memory keep growing, or does it stay around 15?
It grows and shrinks about .2 mbs every time
08-11-2010, 09:56 PM
#17 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
That doesn't answer my question.
Edit: Ok, if you were leaking, then you would continue to grow and grow. If it stays the same, you aren't leaking.
08-11-2010, 10:00 PM
#18 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
when running it in instruments, the leaked bytes just keeps growing and the memory used keeps growing and growing.
08-11-2010, 10:03 PM
#19 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
Get your story straight. Just a minute ago you said it would grow and shrink.
So since you are using Instruments, you should be able to figure out what kind of objects are leaking.
08-11-2010, 10:07 PM
#20 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
Get your story straight. Just a minute ago you said it would grow and shrink.
So since you are using Instruments, you should be able to figure out what kind of objects are leaking.
It tells me the only leak discovered is an array.
08-11-2010, 10:08 PM
#21 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
Ok, are you using any arrays in this view controller?
08-11-2010, 10:12 PM
#22 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
Ok, are you using any arrays in this view controller?
No, but I have many in the rest of the app.
08-11-2010, 10:13 PM
#23 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
Start tracking those down, then.
08-11-2010, 10:14 PM
#24 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
Quote:
Originally Posted by
BrianSlick
Start tracking those down, then.
Ok
08-11-2010, 10:24 PM
#25 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 28
I have released all of the arrays and it still gives me warnings for them leaking memory and now the app is really slow and then it crashes.
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38