Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
i think i understand memory leaks for the most part, but the icon for object allocations in Instruments is equally as forbidding and would like some help understanding a few things.

what potential problems can occur with continuos object allocation? i have a timer that allocates and releases an object every second... the object is a string that changes... an actual timer... i've noticed in the instruments window, under "Overall Bytes" and "#Overall" that the top listed categories continuously rise when my timer is running... is that ok/normal?

what if someone left this timer of mine on for a month and the number kept rising and rising?
 

Attachments

  • Picture 1.jpg
    Picture 1.jpg
    60.4 KB · Views: 128

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
Overall is fine. That's "all the bytes that have ever been allocated". Net bytes is the number of allocated bytes that haven't been deallocated.
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
ok... so if i've allocating memory and then releasing it once per second, that's fine? i mean, i think because the program has to allocate a new memory block every second then it's maybe using more resources than it has to? i don't know... i think i've been reading too many really old books about the dangers of hogging resources when today's PCs are super computers compared to what they were 20 years ago...

as someone who knows little about allocating memory for objects, is there something that i *shouldn't* do when it comes to memory allocation? maybe there's a common mistake for novice programmers that i should know about? i ask simply because i don't pay attention to what i'm allocating, just as long as it's released...
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
There should be no net effect to allocating and deallocating an object, other than more oblique things like memory fragmentation, etc., but that is really not something you should be concerned with. My question would be, why not use an NSMutableString, or some other mutable object for this purpose so you don't have to alloc/release over and over again? It's not hurting anything but performance (and probably that is only altered very slightly) allocating each time, but there's probably not a need to do so.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.