> On Jul 14, 2022, at 3:58 AM, Christopher Snowhill <ch...@kode54.net> wrote:
> 
> My app, Cog (https://cog.losno.co <https://cog.losno.co/> / 
> https://github.com/losnoco/Cog <https://github.com/losnoco/Cog>) is hitting 
> the stack size limit of 512 KiB on macOS. I am not even making heavy use of 
> local variables. I am, however, making a lot of Cocoa object allocations and 
> deletions, and using several nested autoreleasepools, and somehow, this, 
> combined with the C/C++/assembly libraries my app is using for file decoding, 
> hits the stack size limit.
> 
> I had to raise it for some recent additions. The recent additions do not use 
> local variables most of the time. In fact, they all use new/delete or 
> malloc/free already for large memory allocations. Yet somehow, I am hitting 
> the stack size limit rather easily.
> 
> I wish there were some sort of tool in Instruments that could organize memory 
> allocations in use throughout the process by which ones are specific to the 
> stack, so I could locate why my stack size is so grossly inflated.
> 
> I've already added a bodge for file playback threads by invoking NSThread 
> with setStackSize before starting it, but I also hit the limit with metadata 
> reading threads, which are invoked by NSOperationQueue, where I don't have 
> control over the stack size limit.

Disregard that. It turns out it's a very bad idea to allocate 4096 or 8192 
sample buffers on the stack, especially in floating point format, and for the 
maximum allowed channels count of 32. That's 512KiB in itself, or 1 MiB for the 
8192 sample one. I've moved more buffers to class members, and fixed my stack 
size problems.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to