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.
精彩评论