Re: static variables - VSZ and RSZ size (266 Views)
Reply
Occasional Advisor
tanmay patil
Posts: 9
Registered: ‎08-26-2009
Message 1 of 5 (266 Views)

static variables - VSZ and RSZ size

Hi ,

If we have static global variables in our program , will we have increase the VSZ/RSZ memory of our program
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 2 of 5 (266 Views)

Re: static variables - VSZ and RSZ size

Hi:

If I understand your question, you need to examine:

# ulimit -a

...with regard to 'data' (for the heap) and perhaps (though unlikely) for the 'stack'. These are your "soft" limits.

The kernel parameters 'maxdsiz' and 'maxssiz' govern the "hard" limits for these respectively, for 32-bit processes. 'maxdsiz_64bit' and 'maxssiz_64bit' are the hard limits for 64-bit processes.

http://docs.hp.com/en/B2355-60130/maxdsiz.5.html

http://docs.hp.com/en/B2355-60130/maxssiz.5.html

http://docs.hp.com/en/B2355-60130/sh-posix.1.html

Regards!

...JRF...
Acclaimed Contributor
Dennis Handly
Posts: 25,277
Registered: ‎03-06-2006
Message 3 of 5 (266 Views)

Re: static variables - VSZ and RSZ size

>If we have static global variables in our program, will we have increase the VSZ/RSZ memory of our program

If you have static storage duration variables, these increase your VSZ.

As JRF says, if these are large, you may have to increase maxdsiz.
Occasional Advisor
tanmay patil
Posts: 9
Registered: ‎08-26-2009
Message 4 of 5 (266 Views)

Re: static variables - VSZ and RSZ size

Hi ,

Actually we are trying to optimise memory taken by processes .
Some of static variables are arrays which are initialised at the declaration itself and used by all functions in the file .
Is there way to optimise this memory consumption ? If we make these arrays as local , it would be problem for runtime allocation on stack .

Also how do we typically optimise the memory taken by processes .
Also we are using pmap to study the memory utilisation . is there better tool
Acclaimed Contributor
Dennis Handly
Posts: 25,277
Registered: ‎03-06-2006
Message 5 of 5 (266 Views)

Re: static variables - VSZ and RSZ size

>we are trying to optimise memory taken by processes.

How many users of the program are running at once? How much memory?

>Some of static variables are arrays which are initialised at the declaration itself and used by all functions in the file.

Is this read only data? If so, add const.

>If we make these arrays as local, it would be problem for runtime allocation on stack.

The stack would have to be made big enough and you would have to initialize your arrays on every call.

>how do we typically optimise the memory taken by processes.

Allocate it on the heap when you need it.

>is there better tool

For static storage, you can just use size(1).
For heap, you can use mallinfo(3).
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.