Page 5 of 5

Re: Animated Sprites for the Chili framework?

Posted: August 11th, 2017, 5:44 pm
by albinopapa
Step 2: Start commenting out classes and code to see if the report changes, started with the latest class.

Code: Select all

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.

Re: Animated Sprites for the Chili framework?

Posted: August 11th, 2017, 6:51 pm
by albinopapa
Ok, really step one was to look at the MSDN for _CrtDumpMemoryLeaks.

I added these to the top of Main.cpp

Code: Select all

#define _CRTDBG_MAP_ALLOC  
#include <stdlib.h>  
#include <crtdbg.h>  
I added this to the top of WinMain

Code: Select all

	_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.

Re: Animated Sprites for the Chili framework?

Posted: August 12th, 2017, 2:35 am
by albinopapa
K, I think this one:

Code: Select all

{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.

Re: Animated Sprites for the Chili framework?

Posted: August 12th, 2017, 2:56 am
by albinopapa
Kind of forgot to do this, so...
Uploaded to the ParticleEffects_Memleaks branch.

Re: Animated Sprites for the Chili framework?

Posted: August 12th, 2017, 10:51 am
by albinopapa
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.

Re: Animated Sprites for the Chili framework?

Posted: August 12th, 2017, 10:53 am
by albinopapa
the down side is I broke some things while trying to fix it, will fix the test Monday probably.

Re: Animated Sprites for the Chili framework?

Posted: August 12th, 2017, 5:31 pm
by albinopapa
Ok, fixed the broken stuff, here's the commit log:
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.

Re: Animated Sprites for the Chili framework?

Posted: August 14th, 2017, 1:05 am
by chili
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.

Re: Animated Sprites for the Chili framework?

Posted: August 14th, 2017, 5:58 am
by albinopapa
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.