Faraona
Faraona

Reputation: 1700

Is it normal that my cocos2d app increase real memory usage every second?

I develop cocos2d iOS app for iPad. When I test memory leaks and object allocation my Live Bytes are stable, but when I run Activity Monitor I see that the Real Memory Usage of my app increase every second with 0.02MB.

I want to ask is it normal and did someone have similar problems?

Upvotes: 1

Views: 1197

Answers (3)

Faraona
Faraona

Reputation: 1700

I remember that I have this problem because I log debug messages!

I logging this messages in loop cycles (every frame) and this was the reason why the memory increasing!

Please clear or comment all log messages, this will slove your problem :)

Upvotes: 0

PWiggin
PWiggin

Reputation: 966

A year later and I had this exact question. Turned out, I had zombies enabled and that was responsible for my increase in memory every second.

Upvotes: 1

Moshe
Moshe

Reputation: 58097

This is entirely plausible, because Cocos2d (at least the 0.9.x and 1.0 branches) tends to autorelease everything. This can lead to memory build up on situations where you're spawning a lot of sprites onscreen in a loop. If you're indeed autoreleasing and not leaking, adding an autorelease pool along with your loop may be a quick fix. That said, you might actually be leaking.

To debug memory leaks, I'd start with the Leaks Instrument and perhaps the Allocations instrument as well. In Xcode, hit Command + I, or Product -> Profile

Xcode build menu

Once you've got the profiler open, you'll see a menu which contains a bunch of debugging instruments:

Instruments selection menu

Once you select leaks, you'll see this handy windows with all kinds of useful information:

enter image description here

On top, you'll see memory allocations and leaks as a graph. On the bottom you can see all kinds of useful information, such as what objects are allocated, how much memory is in use, and a lot more.

For a full treatment of Xcode debugging with instruments, check out this handy Apple Developer video (login required).

Upvotes: 1

Related Questions