Liam Howlett
|
limiting processes stack usage with setrlimit() issue
|
Liam Howlett
07/22/2009 11:39 AM
post34325
|
limiting processes stack usage with setrlimit() issue
hey,
I'm still trying to reduce memory usage in our application load. I noticed our watchdog process that writes to one area
of memory every so often is using over 600KB. The IDE says that thread 1 has 500K of unallocated stack memory. There
is only one thread, so I think that a direct setrlimit should work as per the definition of RLIMIT_STACK
I tried using the setrlimit call on RLIMIT_STACK to limit it to 50KB in main, but nothing changes.
Code snippit:
getrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur=50*1024;
rlim.rlim_cur_hi=50*1024;
rlim.rlim_max=50*1024;
rlim.rlim_max_hi=50*1024;
int rc = setrlimit(RLIMIT_STACK, &rlim);
rc is zero, so setrlimit worked.. but the stack still has a huge chunk of memory unallocated (and reserved from what I
understand).
Is this the correct method of limiting large stack allocations for a process that does not need that much? What am I
doing wrong?
Any ideas are appreciated.
Thank you,
Liam
|
|
|