How to test the stack size a c complex program requires on LINUX?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm not sure I understand your question, but it will depend on what is declared in each stack frame, how much recursion is used, and so on. Is there any way to post a simplified version of what you're doing, to shine some more light on your question?
Are you looking to use the smallest feasible stack for a given program? Debugging a stack overflow? I think the more you can say about what you're trying to accomplish, the better people will be able to help.
probably valgrind (or other tool) can analyze your code. That means you run it and use it and finally valgrind will create a report for you about memory usage, heap, stack, whatever. But probably there are other, better tools available out there.
Didn't we take Algorithms in school and learn that modeling maximum stack size is technically unsolvable?
You can approximate this. But things like optimization, indirect function pointers, recursive functions, and overall system complexity make it near impossible to attain anything accurate.
There are techniques to detect overflow and monitor stack usage, however they require pre-defined conditions such as known stack locations, size, and pre-seeding of the stack with patterns, while monitoring software is also used.
@rtmistler understood that stack size is a runtime thing, can't get it until actually running it.
Just need to give users some ulimit -s guidance instead of using unlimited to run the program without crash.
For example, Oracle 11g suggest a minimal stack size of 10240K, up to 30720K
---------- Post added 06-24-15 at 03:31 PM ----------
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.