core dumped when adding to vector

Anakreon Mendis anakreonmejdi@yahoo.gr
Mon Jun 27 10:32:00 GMT 2005


> I would indeed be deeply shocked if there is a bug in vectors of enums. 
> However, if someone has a 5 line example which they believes shows a bug 
> in libstdc++ or gcc, I would have thought that bugzilla would be the 
> right place to post it (I'm happy to be told that that isn't the right 
> place)
> 
> Chris

In my program the problem occurs always but can not reproduce it
in a 10 line program. The problem should be in my code, not in the vector.

I run valgrind and gdb and have attached their output. I need some help
on this issue because I have limited experience on C++. I have programmed
mostly in Java where such problems do not occure.

I readed from the FAQ of the libstdc++ about memory management how
to install a custom handler for out-of-memory events. This is the code:

void mem_handler() {
   rusage* usg = new rusage;
   getrusage(RUSAGE_SELF, usg);
   cout << "ru_maxrss:" << usg->ru_maxrss << endl
	   << "ru_ixrss:" << usg->ru_ixrss << endl
	   << "ru_idrss:" << usg->ru_idrss << endl
	   << "ru_isrss:" << usg->ru_isrss
	   << endl;
   delete usg;
   cerr << "Running out of mem" << endl;
   set_new_handler(old_handler);
}

The output is:
ru_maxrss:0
ru_ixrss:0
ru_idrss:0
ru_isrss:0
Running out of mem
Aborted

I need a way to determine how much memory the program
is using. getrusage was not the answer on this problem.
The `time' command did not the job either.

I used top in batch mode to figure out the amount of memory used.
This is the output from 3 runs:
  1460 anakreon  16   0   640  640  548 R 12.5  0.3   0:00.01 simulator 

  1461 anakreon  16   0  1316 1312 1144 R 24.1  0.7   0:00.02 simulator 

  1462 anakreon  16   0  1284 1280 1112 R 25.0  0.7   0:00.02 simulator 

where 0.3 and 0.7 are the percentage of memory used.

 From top it seems that the amount of memory is neglible.

I do understand that the mail is lengthy and this is not the right
place for this question but I need to meet a deadline and the situation
is strange.
I'd really appreciate if someone can give a hint on what's going on
or how could i see the amount of memory used from inside the program.

Anakreon
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gdb_output
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050627/f02f7d6d/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: valgrid_output
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050627/f02f7d6d/attachment-0001.ksh>


More information about the Libstdc++ mailing list