local buffer size

local buffer size

Post by r_konjet » Sun, 30 Jul 2006 09:09:12


I am developing a dll library used by XP embedded, XP and Windows 2000
applications. How big of a local buffer is ok? None of these functions
are recursive but some of my functions will internally call some other
function meaning stack required in the system can be two or three times
more than required for one function. I am thinking of stack problems if
I define a big local buffer (buffer of 50K ) in functions. I am sure I
wont need more than 50 K for the function because of other constraints.
Should I allocate memory dynamically and free it before leaving the
function. My arguement is defining local buffer is kind of dynamic
memory because stack is released after the function call. Is it a good
practice to define big buffers on stack. At what buffer size should I
stop allocating local buffer and allocate a dynamic buffer.

Thanks,
Raj
 
 
 

local buffer size

Post by Maxim S. S » Sun, 30 Jul 2006 11:13:08

> Should I allocate memory dynamically and free it before leaving the

Yes.

Note: the kernel stack for most threads is 12KB only. Sorry, no 50KB local
buffers.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
XXXX@XXXXX.COM
http://www.yqcomputer.com/

 
 
 

local buffer size

Post by r_konjet » Sun, 30 Jul 2006 11:50:36

Is 50K local buffers ok for user mode ?
 
 
 

local buffer size

Post by Maxim S. S » Sun, 30 Jul 2006 12:09:27


Yes.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
XXXX@XXXXX.COM
http://www.yqcomputer.com/