Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4, 5
Author Message
 Post Posted: August 11th, 2017, 5:44 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Step 2: Start commenting out classes and code to see if the report changes, started with the latest class.
Code:
Detected memory leaks!
Dumping objects ->
{258} normal block at 0x000001FD92F37950, 8 bytes long.
 Data: <`       > 60 DC D5 94 FD 01 00 00
{173} normal block at 0x000001FD99C8F650, 160 bytes long.
 Data: <         b      > 00 00 00 00 00 00 00 00 00 62 FA 92 FD 01 00 00
{165} normal block at 0x000001FD92F377C0, 16 bytes long.
 Data: <        `R      > 00 00 00 00 CD CD CD CD 60 52 D5 94 FD 01 00 00
{137} normal block at 0x000001FD92F374F0, 16 bytes long.
 Data: <P               > 50 0F F1 92 FD 01 00 00 00 00 00 00 00 00 00 00
{97} normal block at 0x000001FD92F10E40, 304 bytes long.
 Data: <        0*      > 00 9D 88 B3 F6 7F 00 00 30 2A 89 B3 F6 7F 00 00
Object dump complete.


Down to 5.

So the first three are related to the new particle demo scene for conical emitters.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 11th, 2017, 6:51 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Ok, really step one was to look at the MSDN for _CrtDumpMemoryLeaks.

I added these to the top of Main.cpp
Code:
#define _CRTDBG_MAP_ALLOC 
#include <stdlib.h> 
#include <crtdbg.h> 


I added this to the top of WinMain
Code:
   _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
   _CrtSetReportMode( _CRT_WARN | _CRT_ERROR , _CRTDBG_MODE_DEBUG );
   // and at the end of WinMain
   int hasLeaks = _CrtDumpMemoryLeaks();
   

As stated here.
It doesn't give me line numbers or file names, I'm assuming because I'm using the stack, containers and smart pointers for all allocations.

One of the things I'm doing is storing particles in the emitter class during the spawn function, then I move them out using std::move() after I spawn them. I did this because you can move the emitter to a new location and spawn more particles before retrieving the whole vector. This allowed me to spawn new particles from the emitter and remove dead particles from the effect before collecting and adding them to the effects particle list. I'll have to try having a vector of vectors of particles in the effects class and see if that has any effect on the leaks or just create a destructor in the emitters that clears the vector of particles.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 12th, 2017, 2:35 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
K, I think this one:
Code:
{258} normal block at 0x000001FD92F37950, 8 bytes long.
 Data: <`       > 60 DC D5 94 FD 01 00 00

was because I use a unique_ptr for the static classes WicInitializer and DWriteInitializer and I believe static variables don't get released until program exit which would be after the call to _CrtDumpMemoryLeaks. Created a static void Release() function in each of the initializer classes and a handler class that will instantiate at the beginning before Game and destruct at the end of the try block.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 12th, 2017, 2:56 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Kind of forgot to do this, so...
Uploaded to the ParticleEffects_Memleaks branch.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 12th, 2017, 10:51 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
K, found all the leaks. Chili lead me to looking to memory dumps and I luckily saw some familiar text. It lead me to look in the text class, then to the font class where I had some logging code which used a static member. Even though I use smart pointers, they won't get released until after the leak check.

Released the resources before the check and bam, no more leaks.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 12th, 2017, 10:53 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
the down side is I broke some things while trying to fix it, will fix the test Monday probably.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 12th, 2017, 5:31 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Ok, fixed the broken stuff, here's the commit log:
Quote:
Added conical emitter class
Fixed the emitters
Added static void Release functions to the Loggers as well.
Renamed InitHandler to StaticHandler and moved it to it's own file.
Moved some comments around.
Removed references to debug test code


The master branch has been updated to include these updates.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: August 14th, 2017, 1:05 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3448
Location: Japan
I tried to get the particle system working for the update video but had no idea what button you're supposed to press in the demo to spawn any.

_________________
Chili


Top 
 Profile  
Reply with quote  
 Post Posted: August 14th, 2017, 5:58 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
The WaveBeam affect is triggered with the space bar to fire and left/right arrows to spin. The flames and fireworks stuff is automatic.

Perhaps you grabbed it before I got all three working again?

Thanks for the plug.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4, 5

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: