aCC STL String default capacity() - HP UX
This is a discussion on aCC STL String default capacity() - HP UX ; hi all,
i am using B.11.11 with HP aC++ Compiler (S800) C.03.37.01.
---------------------------------------------------------------------------------------------------
#include
#include
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
...
-
aCC STL String default capacity()
hi all,
i am using B.11.11 with HP aC++ Compiler (S800) C.03.37.01.
---------------------------------------------------------------------------------------------------
#include
#include
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
-
Re: aCC STL String default capacity()
bekz 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.
-
Re: aCC STL String default capacity()
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
wrote:
> bekz 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.
-
Re: aCC STL String default capacity()
On Dec 5, 11:51 am, bekz 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>
-
Re: aCC STL String default capacity()
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.