On Mon, 2009-06-15 at 16:57 +0200, Andreas Berger wrote: > I notice that TThread calls BeginThread (Windows API) with the default > stack size which is 1MB. Is there a way (cross platform) to reduce this > size? I am writing an app that uses up to 200 threads that need > absolutely no stack (I would still give them around 10K). That makes > about 200MB of lost memory.
You need to create a custom class that inherits from TThread. In the constructor of your class you can specify a stack size using an "inherited" statement. If you want some sample code, just ask. Note also that stack sizes go in multiples of 4KiB (or whatever the page size is on the target platform). Moreover, there are no threads that "need absolutely no stack", as there can be compiler-generated temporary locations, as well as register save areas, that must be placed on the stack. So, even if you don't create any local variables, the compiler will expect some stack space to be available. -- Regards, Dave [RLU #314465] ======================================================================= [email protected] (David W Noon) ======================================================================= -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
