push_back in vector fails with malloc failing to assign further memory
-
09-12-2019 - |
Question
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?
Solution
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.
OTHER TIPS
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.