views:

478

answers:

3

I have just finished ridding my project of leaks, but there are still thousands of objects under the category "GeneralBlock-0". The number of net allocations is through the roof (its approaching a million as I type) but none of them are leaks and none of them have a size greater than 0 bytes.

UPDATE & EDIT:

QuartzCore is responsible for all of the offending objects.

The responsible callers are (in order of execution per iteration of the game loop:

-[CALayer setPosition:]
x_hash_table_new_  // x2
hash_table_modify
-[CALayer setPosition:] // x9
-[CALayer(CALayerPrivate)_copyRenderLayer:flags:] //x13

When run on a device, 48 byte sized objects are allocated under GeneralBlock-64, 128, 256 etc. with these same properties as described above. This is unacceptable since it obviously causes a significant slow down. This is what code in my project the problem is traced to:

topRow.center = CGPointMake(topRow.center.x,topRow.center.y-PIXELS_PER_FRAME);
while (nextRow = thisTopRow.below) { //stops running when thisTopRow.below is nil
    nextRow.center = CGPointMake(nextRow.center.x,nextRow.center.y-PIXELS_PER_FRAME);  
    if (nextRow.center.y+20 < 401 && !nextRow.userInteractionEnabled)
        [nextRow enableInteraction];  
    thisTopRow = nextRow;
}

I was under the impression that CGPoint was a type, and would be deallocated at the end of the block of code. Why is it hogging my memory? If it comes down to it, I will upload the trace file I saved in instruments for anyone interested, but I'm pretty sure I covered everything.

+1  A: 

Assuming you can duplicate the behavior under the Simulator, check to make sure your application's RSIZE is not also increasing using 'top -u' in a Terminal.

This is most likely because QuartzCore has implemented its own allocator and allocation zone, but has not fully hooked into the statistics gathering mechanism that Instruments uses.

Please file a bug.

bbum
You lost me there... can you explain what you're trying to tell me in layman's terms?
Tozar
The `top` command displays information about processes. Bill is suggesting running top from Terminal and observing the behavior of RSIZE (resident memory size) for your application. He's suggesting that Instruments may not be monitoring QuartzCore memory, which may be allocated in a different zone (memory region) than the default for "normal" Objective-C objects. Basically, if Instruments says you have massive leaks, but `top` shows that RSIZE stays stable, then Instruments is wrong because it's not getting the correct stats for QuartCore memory. If so, file a bug — http://bugreport.apple.com
Quinn Taylor
A: 

Same problem too... Zero bytes are being allocated in simulator but in device for each method call in CALayer is raising my memory with 48 bytes .

This result in memory issues.

Murali.

Yes, you and niv are experiencing the same problem I am. I too am getting the 48 byte allocation cost for every instance of UIImageView changing location only on the device, but I'm not using a UIScrollView.Also, bear in mind that you have posted an answer when this post doesn't offer an answer to the question. In the future, please use the "add comment" button below the question to make a comment and reserve the "Answers" section for solutions.
Tozar
A: 

I'm dealing with this issue as well. I'm using A UIScrollView with some UIImageViews inside of it, and every time the scroll view's offset changes there is a call to -[CALayer(CALayerPrivate) _copyRenderLayer:flags:] being made that raises the memory by 48 bytes.

Again – on the Simulator this is logged as 0 bytes, yet on my Device it's constantly eating away at my memory.

This is also an issue that comes up for me.Please see the comment on Murali's post. As a new user it's something you'll need to read.
Tozar