-1

I have a code in Which the call to push_back fails for me . The mdb gives me the following clue .

::dem malloc+0x49~ malloc+0x49~ == malloc+0x49~ ::dem __1cIallocate4CpnGrnc_JO__6FipTA_3_+0x2a~ __1cIallocate4CpnGrnc_JO__6FipTA_3_+0x2a~ == __type_0*allocate ::dem __1cJallocator4CpnGrnc_JO__Iallocate6MI_p1_+0x20~ __1cJallocator4CpnGrnc_JO__Iallocate6MI_p1_+0x20~ == rnc_JO**allocator::allocate ::dem __1cGvector4CpnGrnc_JO__Kinsert_aux6Mp1rk1_v_+0xac __1cGvector4CpnGrnc_JO__Kinsert_aux6Mp1rk1_v_+0xac == void vector::insert_aux ::dem __1cGvector4CpnGrnc_JO__Jpush_back6Mrk1_v_+0x4e __1cGvector4CpnGrnc_JO__Jpush_back6Mrk1_v_+0x4e == void vector::push_back ::dem __1cIallocate4CpnGrnc_JO__6FipTA_3_+0x2a __1cIallocate4CpnGrnc_JO__6FipTA_3_+0x2a == __type_0*allocate ::dem __1cGvector4CpnGrnc_JO__Jpush_back6Mrk1_v_+0x4e __1cGvector4CpnGrnc_JO__Jpush_back6Mrk1_v_+0x4e == void vector::push_back`

I dont know How can this be corrected ?. What i know that there is an allocated space Which is actually bigger than the vector size . If that space is utilised it will reassign and copy all data to second location.

What i also know that vector macx_size is a very large value and this should not fail for my code as i am not inserting so many values. Can you let me know What shoould i be debugging for?

iammilind
  • 68,093
  • 33
  • 169
  • 336
Invictus
  • 4,028
  • 10
  • 50
  • 80
  • 2
    Did you use `valgrind` or some other tools to check against memory leak or curruption? – Basile Starynkevitch Mar 08 '12 at 08:33
  • "`macx_size` is a very large value and this should not fail for my code as i am not inserting so many values" The value of `max_size` is the maximum number of elements that the vector can hold, not the minimum. Being the minimum would mean it could hold those for sure. Being the maximum means that for sure it cannot hold more than those; it may fail before it reaches that size. – R. Martinho Fernandes Mar 08 '12 at 08:43
  • @BasileStarynkevitch No , I havent use `valgrind` . I dont know How to use it . – Invictus Mar 08 '12 at 08:47
  • Create an example of about 20 lines of code, which reproduces the problem. – Peter Wood Mar 08 '12 at 08:47
  • @R. Martinho I will try and print the max_size and current size of my vector and see if the threshold is reached – Invictus Mar 08 '12 at 08:48
  • @Ritesh: use "valgrind " – mahmood Mar 08 '12 at 08:48

2 Answers2

1

One way to check is to monitor the free memory on your system together with the memory that your application is using.

  • If the memory usage of your application keeps growing, then you probably have a memory leak.
  • If there is less free memory than your application needs, then you have a resource issue.
stefaanv
  • 14,072
  • 2
  • 31
  • 53
0

This seems to be a memory problem, I doubt that the list is abnormal before push_back is called. My suggestion is to reduce the operations on this list step by step, to find out which operation causes the list to be abnormal.

ciphor
  • 8,018
  • 11
  • 53
  • 70