Jump to content
dragon.star

Memory Leaks with blank project [C++]

Recommended Posts

Greetings,

I've created a new blank project in the LE editor and loaded the solution in VS.

Without modifying anything (leaving the default interpreter code intact), i get the following in the log when the app exits.

 

Detected memory leaks!
Dumping objects ->
{188} normal block at 0x070461A8, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{187} normal block at 0x07042178, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{186} normal block at 0x0703E148, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{184} normal block at 0x0703A118, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{183} normal block at 0x070360E8, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{182} normal block at 0x070320B8, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{181} normal block at 0x0702A008, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{180} normal block at 0x07019F58, 65664 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{179} normal block at 0x07011EA8, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{178} normal block at 0x07009DF8, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{177} normal block at 0x07001D48, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{176} normal block at 0x06FF9B18, 33280 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{175} normal block at 0x06FE1AA8, 98368 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{169} normal block at 0x06F39B58, 8 bytes long.
 Data: <     { V> 18 1E FD 06 80 7B 0E 56 
{163} normal block at 0x06F39228, 8 bytes long.
 Data: <$    { V> 24 1D FD 06 80 7B 0E 56 
{162} normal block at 0x06FD1C60, 2720 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{161} normal block at 0x06FD1AE0, 336 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{159} normal block at 0x03EEE500, 760 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{145} normal block at 0x03E49590, 1144 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{144} normal block at 0x03E27D90, 528 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{127} normal block at 0x06070338, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{126} normal block at 0x0606C308, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{125} normal block at 0x060682D8, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{124} normal block at 0x060642A8, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{118} normal block at 0x06060278, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{117} normal block at 0x03EE8BD0, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{116} normal block at 0x03E445E0, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{115} normal block at 0x060581C8, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{114} normal block at 0x06048118, 65664 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{113} normal block at 0x06040068, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{112} normal block at 0x03EE0B20, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{111} normal block at 0x03ED8A70, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{110} normal block at 0x03ED0840, 33280 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{109} normal block at 0x03EB87D0, 98368 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{103} normal block at 0x03D60D08, 8 bytes long.
 Data: <  O  { V> D8 90 4F 01 80 7B 0E 56 
{97} normal block at 0x03D602C0, 8 bytes long.
 Data: <  O  { V> E4 8F 4F 01 80 7B 0E 56 
{96} normal block at 0x014F8F38, 2720 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{94} normal block at 0x0150E408, 336 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
Object dump complete.

 

 

I also removed all the interpreter code in App::Start and Loop and created a window, world, and a context and they are released in the App destructor.

#include "App.h"

using namespace Leadwerks;

App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}

App::~App()
{ 
	context->Release();

	delete world;
	delete window; 
}

bool App::Start()
{
	window = Leadwerks::Window::Create("3D Window", 120, 70, 1280, 720, Window::Titlebar);
	context = Context::Create(window);
	world = World::Create();



	return true;
}

bool App::Loop()
{
	if (window->KeyDown(Key::Escape) || window->Closed())
		return false;

	return true;
}

 

The log still reports leaks but with different blocks and sizes:

 

Detected memory leaks!
Dumping objects ->
{159} normal block at 0x04E1D8E8, 760 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{145} normal block at 0x04D53978, 1144 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{144} normal block at 0x063A5998, 528 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{127} normal block at 0x0639C1A8, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{126} normal block at 0x06398178, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{125} normal block at 0x06394148, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{124} normal block at 0x06390118, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{118} normal block at 0x04E17248, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{117} normal block at 0x04E13218, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{116} normal block at 0x04E0F1E8, 16384 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{115} normal block at 0x04E07138, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{114} normal block at 0x06380068, 65664 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{113} normal block at 0x04DFF088, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{112} normal block at 0x04DF6FD8, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{111} normal block at 0x04DEEF28, 32896 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{110} normal block at 0x04DE6CF8, 33280 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{109} normal block at 0x04DCEC88, 98368 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{103} normal block at 0x04D60070, 8 bytes long.
 Data: <     {!V> D8 D8 D2 04 80 7B 21 56 
{97} normal block at 0x04D5FEE8, 8 bytes long.
 Data: <     {!V> E4 D7 D2 04 80 7B 21 56 
{96} normal block at 0x04D2D730, 2720 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
{94} normal block at 0x04C916F8, 336 bytes long.
 Data: <cccccccccccccccc> 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
Object dump complete.

I'm just wondering if they are real leaks or a false flag, any thoughts?

 

Thanks!

Share this post


Link to post

The lua interpreter does a lot of memory allocating and deallocating, causing these false positives to show up.

See more here: 

 

  • Like 1

Share this post


Link to post

If it's only occurring at exit it's not really a leak. Some programmers like to manually free all resources when a program ends, which seems like a huge waste of time to me since the OS deletes it all anyways.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Create Your Account

Sign in

Already have an account? Sign in here.

Sign In Now
×