• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation


  • Subject: Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
  • From: Leo Singer <email@hidden>
  • Date: Thu, 19 Feb 2009 13:29:27 -0500

Sorry, I meant to send this to the list.

Leo


---------- Forwarded message ----------
From: Leo Singer <email@hidden>
Date: Thu, Feb 19, 2009 at 1:28 PM
Subject: Re: Running out of memory on stack in C++ routine invoked
within  Cocoa NSOperation
To: Greg Parker <email@hidden>


Thanks for all of the input on this.  I decided to override
NSOperation's - start selector and make the thread myself.  I wish
that there was a way to adjust the stack size per NSOperationQueue.
Maybe I should report that as a feature request.

I would rather not dynamically allocate that particular array because
the Cocoa application I am developing is simply a wrapper for a cross
platform C++ project.  This particular project has to manage a number
of different resources, including an SQLite database connection, an
open file, and a serial port device.  In order to keep error handling
as simple as possible, I have made heavy use of the RIAA pattern.  If
a serial port error occurs, for example, an exception gets thrown.  As
a result, the objects representing both the database and the open file
go out of scope, and their resources are released.

A std::vector would be unsuitable also because in my actual
application (not the cooked example I sent out) I need to be able to
manipulate that memory directly.

Some more background information might be helpful.  The application is
a GUI for a bootloader for Microchip brand DSPs.  The big array in
question is actually a 256 kb image of the device's program memory.

Thanks again,
Leo

On Wed, Feb 18, 2009 at 3:17 PM, Greg Parker <email@hidden> wrote:
> On Feb 18, 2009, at 3:22 AM, Michael Vannorsdel wrote:
>>
>> Really it would be best to malloc the space, use it, and free it.  Once
>> you get to huge stack usage you gamble that you won't run out when there can
>> be other higher up calls also consuming some (frameworks, libs, 3rd party
>> code, ect).  Also if you only use the large amount once in a while then you
>> have a bunch of unutilized memory sitting around.
>
> Agreed: use malloc for large memory allocations.
>
> One other limit that you apparently haven't run into yet: some architectures
> limit the maximum size of a single stack frame, even if there is lots of
> space on the stack. ppc has a maximum 64K stack frame size; arm may have a
> similar limit.
>
>
> --
> Greg Parker     email@hidden     Runtime Wrangler
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
      • From: Michael Ash <email@hidden>
    • Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
      • From: Clark Cox <email@hidden>
    • Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
      • From: Ken Thomases <email@hidden>
    • Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
      • From: Greg Parker <email@hidden>
    • Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
      • From: Mike Abdullah <email@hidden>
References: 
 >Running out of memory on stack in C++ routine invoked within Cocoa NSOperation (From: Leo Singer <email@hidden>)
 >Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation (From: Michael Vannorsdel <email@hidden>)
 >Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation (From: Greg Parker <email@hidden>)

  • Prev by Date: How to make a token field that only accepts numbers: NSTokenField with NSNumberFormatter?
  • Next by Date: what to do with MAC address...
  • Previous by thread: Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
  • Next by thread: Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation
  • Index(es):
    • Date
    • Thread