Method to calculate user space thread size

Mulyadi Santosa mulyadi.santosa at gmail.com
Wed Apr 3 01:36:08 EDT 2013


On Tue, Apr 2, 2013 at 7:55 PM, naveen yadav <yad.naveen at gmail.com> wrote:
> Dear All,
>
> I have very complex user space application contain more then 400 threads. I
> want to limit the stack size in user space, for this I want to know how much
> stack size each thread use in worst case.
>
> To calculate this is I need to modify in kernel ? or current kernel have any
> support ?
> or is there a method I can get from smaps?

try to check /proc/<pid>/status on VmStk line. But IMHO that indicates
the whole stack size (sum of all thread's stack size).

BTW, sure what you want to do is safe? what if you miscalculate it?
Certainly your application would crash some ways. So, maybe you need
other workaround. If you need to reserve memory, perhaps what you need
to do is doing malloc() wisely.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list