Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Strange Problem when allocating heap memory

Author
Message
Shyft
12
Years of Service
User Offline
Joined: 26th May 2012
Location:
Posted: 14th Oct 2012 08:38 Edited at: 14th Oct 2012 22:48
I know this isnt necessarily an issue with GDK but I am using it to make a game so I thought someone here may be able to help me.

Basically I have an STL list and every second I am pushing an object into it. I set up a timer that takes the time in milliseconds right before the new keyword call to build the object. Then inside of the object constructor I store the difference between that time taken and the current clock time FIRST on the initialization list. So I would assume this happens right after memory allocation. Correct me if I am wrong.

So the problem is this. As items are pushed into the list the time for allocation grows from 11ms to over 100ms. That is until the total memory used by my program reaches 65mb. Once that happens the allocation time drops back to 11ms and stays there. This seems very strange to me. I have not included any code because there is no code between the timer start and end. The only thing that happens is the memory allocation.

Any help would be appreciated and if there is somewhere better to post this please let me know. Thanks

UPDATE:

So I have now tried turning the list into a vector, changing from storing pointers to storing objects and changing what object is actually being stored. The problem remains unchanged....

UPDATE:

I don't know if anyone really cares, but for the curious out there I figured out a solution. I realized that a fairly processor expensive task was being done in a member object construction that didnt need to be done except the first time. I I overloaded the constructor for this and now this runs in less than 1 ms

Login to post a reply

Server time is: 2024-11-18 21:57:02
Your offset time is: 2024-11-18 21:57:02