How to identify maximum stack size?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to identify maximum stack size?
# 1  
Old 08-25-2011
How to identify maximum stack size?

Hi All,

I have set max stack size as 4KB for my thread, but it always using very less.
So I like to know what is the maximum stack size is used by my thread.
I tried with gcc -fstack-usage command line option, but its not supported by mips.
Kindly suggest me the way to find the max stack size.

I can't use GDB for my application.


I am using below compiler
Code:
sde-gcc -v
Thread model: mipssde
gcc version 3.4.4 mipssde-6.06.01-20070420

# 2  
Old 08-25-2011
getrusage should do it

Last edited by frank_rizzo; 08-25-2011 at 09:50 AM.. Reason: add man tag
# 3  
Old 08-25-2011
It is not possible to get the max stack usage because it varies...even the RSS value is a sum of text data and stack segments and due to the dynamic nature of the stack it could fluctuate between 0 - 4Kb.
# 4  
Old 08-26-2011
Dear shamrock thanks for the reply.
My requirement is to analyze the stack size of each function at compile time.
I am not expecting 100% of stack usage, at least we can find static information.
# 5  
Old 08-26-2011
Quote:
Originally Posted by rajamohan
My requirement is to analyze the stack size of each function at compile time.
if it's self-contained, i.e. doesn't call external library functions, then the amount of space it takes on the stack will be closely related to the total size of its local variables.

If it calls external functions, how much total stack it needs is going to be hard to guess at compile time.
# 6  
Old 08-26-2011
So is there is any command or compiler option to find the local variable of nested function calls.
Is there is possible to get these information using (readelf or objdump command)? I have tried but i can't.
# 7  
Old 08-26-2011
Quote:
Originally Posted by rajamohan
So is there is any command or compiler option to find the local variable of nested function calls.
Think about what "nested function call" means. The compiler is not omniscient. Does the compiler know how many times this is going to recurse?
Code:
int recur(int num)
{
      if(num>0) recur(num-1);
      return(0);
}

Feed it 1, it consumes 1 stack frame, feed it 2, it consumes 2 stack frames, and on, and on. There's no static total. There's not even a maximum.

Or how about this code:

Code:
int something(void)
{
        external_library_function();
}

The compiler won't know the run-time stack usage of functions it didn't even compile.

What you're asking about is something you need to consider in your algorithm design, or monitor at runtime with a debugger, not something the compiler can fix for you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Cannot set 'soft limits' for 'maximum stack size' for a standard user

Hi Guys, I'm trying to install Oracle Database on to Oracle Linux 7.6 but when the database install package checks the OS set-up, it keeps on failing on the soft limits for the stack. It's default value is 8192 but I'm trying to set it to 10240. This is what I added to... (2 Replies)
Discussion started by: ASGR
2 Replies

2. Shell Programming and Scripting

Maximum size of attachment in mail

Hi Friends, My requirment is to Query the oracle database , generate the file change the extension to .csv and send to clients automatically everyday. However i am able to perform the task. But sometimes when the file size is getting increased more than 1 MB then the mail is... (5 Replies)
Discussion started by: Showdown
5 Replies

3. Programming

Maximum buffer size for read()

Hi friends, Hope everybody is fine. First have a look at my code, then we will talk about it. $ cat copy.c #include <stdio.h> #define PERMS 0644 /* RW for owner, R for group, others */ #define BUFSIZE 1 char *progname; int main(int argc,char * argv) { int f1, f2, n; ... (4 Replies)
Discussion started by: gabam
4 Replies

4. AIX

maximum size of a ramdisk on AIX 5.3

Hi, Do you know what is the maximum size I can use to create a ramdisk on AIX 5.3? I m pretty sure i've seen somewhere i can use more than 2 Gb but I can't remember where. I need to do some recommandations for one of my customer and they'll need to create a ramdisk of 20 Gb. Can this be done? ... (1 Reply)
Discussion started by: cedric hanquez
1 Replies

5. UNIX for Dummies Questions & Answers

Maximum file size ????

Hi All, - block size of 512KB & every address requires 4 bits - The inode structure contains 10 direct pointers, 1 single indirect, 1 double indirect & 1 triple indirect pointer What could be the possible maximum file size for this system Any guess? I am unable to understand the question... (0 Replies)
Discussion started by: preethgideon
0 Replies

6. UNIX for Dummies Questions & Answers

maximum tar file size?

Is there a reasonable maximum limit for tar file sizes? I want to transfer a pile of files from one server to another but have restricted means, so tarring them first will probably be best... but how big can I go - both for the file format itself and for the operating system (linux) to handle? ... (7 Replies)
Discussion started by: Bobby
7 Replies

7. UNIX for Dummies Questions & Answers

Maximum size of a file in unix

What's the maximum file size supported by unix. (3 Replies)
Discussion started by: nagalenoj
3 Replies

8. HP-UX

Mailx Maximum attachment size

Hi friends, what is the maximum allowable attachment size, we can send using mailx command. what is an alternate option if my file is > than that size? thanks sreeji (0 Replies)
Discussion started by: sreejithau
0 Replies

9. Programming

Maximum File Size

Hi, When i checked for the maximum file size on solaris 5.9 the max file size obtained was only 2147483647 and all the further writes to the file which had reached that max size is not added to that file. even i had registered the signal SIGXFSZ, but the signal was not delivered to the... (5 Replies)
Discussion started by: matrixmadhan
5 Replies

10. UNIX for Dummies Questions & Answers

Maximum size of sed file...

The sed -f option (reading sed commands from a file) seems to have a limit of 200 transactions per file. I can't see anything in the man pages about this restriction. I have a file with several thousand sed commands I need to perform (substitutions) - and while I can split the file into... (14 Replies)
Discussion started by: peter.herlihy
14 Replies
Login or Register to Ask a Question