Memory issue when using STL vector

Home / Forums / Marmalade Archive / General Development Questions / Memory issue when using STL vector
5 replies [Last post]
by: dp-development
Status: Offline
Joined: 2011-04-13

Hi all!

I've a memory issue on application exit. It gives me this error:

IwAssert failure (MEMORY, 2356).
Message: Bucket 0(System) is still in use (first allocation ID=141); deleting it is dangerous

Callstack:
IwUtilTerminate
IwGxTerminate
Iw2DTerminate
_IwGxInitPipeline

I've added a MemoryBreakPoint at 141. Here's the call stack at this point:

PartyserviceApp.s86!IwMemoryWatcher::PostRealloc()  + 0x562 Bytes	
PartyserviceApp.s86!IwReallocBucket()  + 0x450 Bytes	
PartyserviceApp.s86!IwRealloc2()  + 0x1f2 Bytes	
PartyserviceApp.s86!IwMalloc2()  + 0x14c Bytes	
PartyserviceApp.s86!_s3eMalloc()  + 0xc Bytes	
PartyserviceApp.s86!__IwMalloc()  + 0xa Bytes	
PartyserviceApp.s86!_malloc()  + 0x9f Bytes	C++
>PartyserviceApp.s86!_STL::__malloc_alloc::allocate(unsigned int __n)  Zeile 110 + 0x9 Bytes	C++
PartyserviceApp.s86!_STL::allocator::allocate(unsigned int __n, const void * __formal)  Zeile 355 + 0x12 Bytes	C++

Here's the code of the cleanup routine:
{syntaxhighlighter brush:c++;collapse:false;first-line:1;}
void CAppManager::Shutdown(void)
{
while (!m_AppStates.empty())
{
m_AppStates.back()->Cleanup();
m_AppStates.pop_back();
}
Iw2DTerminate();
SafeDelete(m_SingletonPtr);
return;
}
{/syntaxhighlighter}

And finally the callstack where the error occurs:

PartyserviceApp.s86!_IwMemBucketTerminate()  + 0x193 Bytes	
PartyserviceApp.s86!IwGxTerminate()  + 0x291 Bytes	
PartyserviceApp.s86!Iw2DTerminate()  + 0x24d Bytes	
>PartyserviceApp.s86!CAppManager::Shutdown()  Zeile 46	C++
PartyserviceApp.s86!IwMain()  Zeile 37	C++
PartyserviceApp.s86!__IwMain()  + 0x41 Bytes	

If u need some more informations, please tell. For explanation: I'm using stl vector for managing the appstates. For now it just starts with an Iw2DInit(), pushing on state on the stack, the render-method of this state just clears the screen and waits for s3eKeyEsc, then quits the App.

I really don't find the issue.

Best regards
dp-development

by: Totee
Status: Offline
Joined: 2011-05-14
Hi! I had the same problem

Hi!
I had the same problem with STL vector, when I put an element into it, I've got a similar error.
Try to move the vector operations (push_back etc.) before Iw2DInit() or IwGxInit() functions. It solved this kind of problem for me. It looks like if these STL operations between the IwXXInit() and IwXXTerminate blocks it cause trouble on the stack.

by: dp-development
Status: Offline
Joined: 2011-04-13
Hi Totee, thanks for reply.

Hi Totee,

thanks for reply. I#ll give it a try and notice if it solved it or not :)

Best regards
dp-development

by: DionisioX
Status: Offline
Joined: 2010-11-02
Take care if you are using

Take care if you are using your own classes with memory allocations.

When inserting elements into vectors, they are being copied, so you need to overload the copy constructor and the = operator and alloc y release memory when needed.

Regards.

by: Rhett L
Status: Offline
Joined: 2011-03-28
Have you considered using
by: dp-development
Status: Offline
Joined: 2011-04-13
Aaah...that really did the

Aaah...that really did the trick! No more issues!

Thx to all for the help!

Best regards
dp-development

Latest Posts

Latest Comments

Top Contributors

  • amanda
  • riaan
  • alexand3
  • alexand4
  • alexand7
  • alexand889
  • alexand12191
  • remote9991
  • remote9992
  • test