Fun with Memory!
Posted March 29th, 2004 @ 07:32pm by Erik J. Barzeski
Fun with memory!
*** malloc: vm_allocate(size=1069056) failed (error code=3) *** malloc[7732]: error: Can't allocate region
PulpFiction has exited due to signal 10 (SIGBUS).
This is what happens when you attempt to process a 9.2 MB file without an autorelease pool inside your processing loop. Wheeee!
Posted 29 Mar 2004 at 8:00pm #
dude, I totally know what you are saying.,
Posted 29 Mar 2004 at 10:52pm #
I have no idea what the hell you're talking about...
...but where's PulpFiction? I don't wanna have to get medieval on your ass.
(Sorry, couldn't resist that.) 😛
Posted 29 Mar 2004 at 11:53pm #
Ouch...
One of these days I will get around to messing with Cocoa again maybe, but for now, I think I'll stick with Java and Python. They are just easier to deal with and better documented. I think if Cocoa had better networking frameworks, I would probably push a little more in that direction, but I can sympathize with the above having coded in both C and Java 1.0 years ago...
Again, Ouch!
Posted 30 Mar 2004 at 4:52am #
Not having to deal with memory management doesn't make java easier. In terms of memory management and footprint Java is a hell of a lot worse, and can't compete if you put some thought into your memory management.
First: if you do things in a loop do the alloc init release version, instead of autoreleased objects,
Second: think about what your doing, maybe you do unneccesary things
Third: think about where your autorelease pools make sense.
And never forget: your memory footprint is important, no matter how high level your programming model is. Using much to much memory, even when temporary, is not acceptable and for me a reason not to use a product at all.
Posted 30 Mar 2004 at 9:45am #
dom, you can't avoid some autoreleased objects, because even the Cocoa frameworks themselves use them sometimes.
btw, adding an autorelease pool fixed the issue, 29574 loop runs and going...
Posted 30 Mar 2004 at 11:57am #
yes, you can't avoid all autoreleased objects, but especially in nested loops, avoiding all autoreleased objects that you can avoid, reduces your memory footprint a great deal.
Posted 31 Mar 2004 at 6:37am #
Dave G - You can use Cocoa with Python or Java. You do lose out on some things with Java, but some of those are simply due to features that exist in Objective-C but don't exist in Java. I haven't used PyObjC, but I hear it's good. Cocoa really is designed for Objective-C, though. And it's hard to beat the speed of compiled code.
- Scott
Posted 24 May 2004 at 6:06pm #
Everyone has moments of immaturity. Moments that are not their shining best. Readers of this blog know that I'm an opinionated, strong-willed guy who will stick to his guns. But readers also know me as someone who will plainly admit...