Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

aCC STL String default capacity()

3 views
Skip to first unread message

bekz

unread,
Nov 1, 2007, 2:46:56 AM11/1/07
to
hi all,

i am using B.11.11 with HP aC++ Compiler (S800) C.03.37.01.

---------------------------------------------------------------------------------------------------
#include <string>
#include <iostream>
int main()
{
std::string test;
printf("test size: %d\n",test.capacity());
test = "becks";
printf("test size: %d length: %d
\n",test.capacity(),test.length());
}
---------------------------------------------------------------------------------------------------

bash-2.05b# aCC -AA simple.cpp
bash-2.05b# ./a.out
test size: 0
test size: 128 length: 5

the same program ran on linux gave me
test size: 0
test size: 5 length: 5

if the program is pretty much string intensive this will result high
memory usage in HPUX.

any suggestions or comments on how to reduce the default capacity
size? do we have any compiler options to deal which this?

thanks
bekz

Paul Pluzhnikov

unread,
Nov 1, 2007, 2:52:24 AM11/1/07
to
bekz <beck...@gmail.com> writes:

> bash-2.05b# aCC -AA simple.cpp
> bash-2.05b# ./a.out
> test size: 0
> test size: 128 length: 5

$ aCC -AA junk.cpp -D_RWSTD_MINIMUM_STRING_CAPACITY=10 && ./a.out
test size: 0
test size: 10 length: 5

$ aCC -AA junk.cpp -D_RWSTD_MINIMUM_STRING_CAPACITY=1 && ./a.out
test size: 0


test size: 5 length: 5

> if the program is pretty much string intensive this will result high
> memory usage in HPUX.

Only if you have a lot of very short strings.
Even then, you are probably guilty of premature optimization.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

bekz

unread,
Dec 5, 2007, 11:51:31 AM12/5/07
to
thanks paul! it solved my problem atleast.....

but i didn't understand what you meant by permature optimzaiton...how
can optimization affect this? do you mean compiler changing back the
string capacity to some different value other than zero?

bekz

On Nov 1, 11:52 am, Paul Pluzhnikov <ppluzhnikov-...@charter.net>
wrote:

OldSchool

unread,
Dec 5, 2007, 2:26:48 PM12/5/07
to
On Dec 5, 11:51 am, bekz <becks...@gmail.com> wrote:
> thanks paul! it solved my problem atleast.....
>
> but i didn't understand what you meant by permature optimzaiton...how
> can optimization affect this? do you mean compiler changing back the
> string capacity to some different value other than zero?
>
> bekz

Nothing to do w/ compiler optimization settings. see:

<http://en.wikipedia.org/wiki/
Optimization_(computer_science)#When_to_optimize>

Dennis Handly

unread,
Jan 10, 2008, 10:46:07 PM1/10/08
to
bekz wrote:
> it solved my problem at least.....

_RWSTD_MINIMUM_STRING_CAPACITY is documented in:
http://docs.hp.com/en/10946/libs.htm#container_alloc

>>> if the program is pretty much string intensive this will result high

>>> memory usage in HP-UX.

If you are using -mt, there is more space wasted.

0 new messages