C++ Compiler STL problem

From: Price, Richard \(REO\) <"Price,>
Date: Fri, 21 Sep 2001 15:57:23 +0100

> Hello,
>
> We are experiencing STL (Standard Template Library) memory problems after
> porting code from Compaq C++ 5.7-002 to V6.1-029 running on Tru64 V4.0F
> Patch DUV40FAS0004.
>
> After initial investigation the problem had been isolated to the
> implementation of STL (Standard Template Library) in the V6.1 compiler
> (maybe later versions as well).
>
> I have produced a simple test program to demonstrate this. It can clearly
> be seen that under certain conditions the code compiled under the new
> compiler can take up as much as 13 times the amount of memory to run the
> same executable, and that memory allocation is very dependent on how STL
> is used and in what order memory is allocated within the sample program.
> (Try changing the order that vectors, sets and lists are allocated in the
> sample program, the results are very different.)
>
> I have tried replacing the STL /usr/include/cxx on the V6.1 machine with
> STL from the 5.7 environment. When the test program was compiled an run,
> the problem disappeared. Thus the problem appears to be in the
> Compaq/RogueWave implementation of STL.
>
> Regards,
>
> Richard Price
>
>
> P.S Test program attached to demonstrate the problem.
>
>
> #include <unistd.h>
> #include <sys/time.h>
> #include <sys/resource.h>
>
> #include <list>
> #include <vector>
> #include <map>
> #include <set>
>
> //using namespace std;
>
> int memuse () {
>
> int status = 0;
> struct rusage ru;
> status = getrusage(RUSAGE_SELF,&ru);
>
> //printf("Process: user time = %d\n",ru.ru_utime);
> //printf("Process: system time = %d\n",ru.ru_stime);
> //printf("Process: integral shared memory size = %d\n",ru.ru_ixrss);
>
> printf("Process: integral unshared data = %d\n",ru.ru_idrss);
>
> //printf("Process: integral unshared stack = %d\n",ru.ru_isrss);
> //printf("Process: Page faults = %d\n",ru.ru_majflt);
>
> struct timeval rtime = ru.ru_utime;
> return rtime.tv_usec;
>
> }
>
> main() {
> int i;
>
> int status;
> printf("Main: Start\n");
> int mem = memuse();
> printf("\n\n");
>
> printf("Main: Create vector set\n");
> vector< set<int> > test(10000);
> mem = memuse();
> printf("\n\n");
>
> for(i = 0; i < 10000; ++i) test[i].insert(i/3);
> printf("Main: Populated vector set\n");
> mem = memuse();
> printf("\n\n");
>
> vector<int> test2(100000);
> printf("Main: Created vector ints\n");
> mem = memuse();
> printf("\n\n");
>
> printf("Main: Populated vector ints\n");
> for(i = 0; i < 100000; ++i) test2.push_back(i);
>
> mem = memuse();
> printf("\n\n");
>
> list<int> test_list(100000);
> printf("Main: Created list ints\n");
> mem = memuse();
> printf("\n\n");
>
> printf("Main: Populated list ints\n");
> for(i = 0; i < 100000; ++i) test_list.push_back(i);
>
> mem = memuse();
> printf("\n\n");
>
>
> status = sleep(60);
>
> }
Received on Fri Sep 21 2001 - 14:58:29 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT