Subscribe to
Posts
Comments
NSLog(); Header Image

Fun with Memory!

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!

8 Responses to "Fun with Memory!"

  1. dude, I totally know what you are saying.,

  2. 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.) 😛

  3. 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!

  4. 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.

  5. 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...

  6. 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.

  7. 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

  8. 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...


Trackback URI | Comments RSS

Leave a Reply to Maturity | NSLog();

Please abide by the comment policy. Valid HTML includes: <blockquote><p>, <em>, <strong>, <ul>, <ol>, and <a href>. Please use the "Quote Me" functionality to quote comments.