Memory consumption for threads

Viewed 46

How will the memory consumption vary in these cases, there is a Process containing 1 thread and there is a Process containing 0 thread.

1 Answers

While this question is too broad to answer, a thread typically need to save its stack, which is anywhere from a few KBs up to 1MB depending on the exact code executed inside the thread.

This is talking only about native C threads, other implementations might save extra data but it's usually safe to assume a thread will stay below 1 MB for most programming languages, and when in doubt just profile the program at hand.

Edit: according to Jérôme, the max memory of the thread stack is 2 MB on linux systems instead of 1 MB for windows.

Related