Animated Sprites for the Chili framework?

The Partridge Family were neither partridges nor a family. Discuss.
albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Animated Sprites for the Chili framework?

Post by albinopapa » August 11th, 2017, 5:44 pm

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Animated Sprites for the Chili framework?

Post by albinopapa » August 11th, 2017, 6:51 pm

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Animated Sprites for the Chili framework?

Post by albinopapa » August 12th, 2017, 2:35 am

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Animated Sprites for the Chili framework?

Post by albinopapa » August 12th, 2017, 2:56 am

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Animated Sprites for the Chili framework?

Post by albinopapa » August 12th, 2017, 10:51 am

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Animated Sprites for the Chili framework?

Post by albinopapa » August 12th, 2017, 10:53 am

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Animated Sprites for the Chili framework?

Post by albinopapa » August 12th, 2017, 5:31 pm

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

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Animated Sprites for the Chili framework?

Post by chili » August 14th, 2017, 1:05 am

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Animated Sprites for the Chili framework?

Post by albinopapa » August 14th, 2017, 5:58 am

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

Post Reply