Im Stumped, Why is UIImage\Texture2d memory not being freed
Posted
by howsyourface
on Stack Overflow
See other posts from Stack Overflow
or by howsyourface
Published on 2010-05-04T02:10:25Z
Indexed on
2010/05/04
2:18 UTC
Read the original article
Hit count: 341
I've been looking everywhere trying to find a solution to this problem. Nothing seems to help.
I've set up this basic test to try to find the cause of why my memory wasn't being freed up:
if (texture != nil)
{
[texture release];
texture = nil;
}
else
{
UIImage* ui = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"]];
texture = [[Texture2D alloc] initWithImage:ui];
}
Now i would place this in the touches began and test by monitoring the memory usage using intstruments at the start (normally 11.5 - 12mb) after the first touch, with no object existing the texture is created and memory jumps to 13.5 - 14
However, after the second touch the memory does decrease, but only to around 12.5 - 13.
There is a noticeable chunk of memory still occupied.
I tested this on a much larger scale, loading 10 of these large textures at a time The memory jumps to over 30 mb and remains there, but on the second touch after releasing the textures it only falls to around 22mb.
I tried the test another time loading the images in with [uiimage imagenamed:] but because of the caching this method performs it just means that the full 30mb remains in memory.
© Stack Overflow or respective owner