开发者

NSImage + memory managament

开发者 https://www.devze.com 2023-03-19 12:20 出处:网络
NSImage *randomImage = [[NSImage alloc] initWithContentsOfURL:imageURL]; [randomImage release]; Why does the memory usage still go up? What is using that memory? I release the NSImage object. ( no,
NSImage *randomImage = [[NSImage alloc] initWithContentsOfURL:imageURL];
[randomImage release];

Why does the memory usage still go up? What is using that memory? I release the NSImage object. ( no, its not the URL 开发者_运维百科)


The images are probably being cached. Take a look at [img setCacheMode:]

Did you actually try doing 500 times or are you guessing at the behaviour? My guess would be that the cache would be cleared at some upper limit - maybe 50mb is not that much?

It is important to note that -release is not equivalent to free() or destroy(), even if you call it immediately after alloc init you shouldn't make the assumption that the object has been cleared away. This is why there is so much hate for the -retainCount abusers that think it is a good way to debug memory management.

0

精彩评论

暂无评论...
验证码 换一张
取 消