Jump to content

Entity::Point Memory Leak c++


norbert
 Share

Recommended Posts

Hello,

 

if i use the point function and context->Sync(false) the memory usage increases continuously.

 

As an example, we take the sample code:

 

The only change is the (context->Sync(false))

 

 

 

#include "App.h"
using namespace Leadwerks;
App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
App::~App() { delete world; delete window; }
Entity* entity1 = NULL;
Entity* entity2 = NULL;
bool App::Start()
{
 window = Window::Create();
 context = Context::Create(window);
 world = World::Create();
 camera = Camera::Create();
 camera->Move(0,1,-3);
 Light* light = DirectionalLight::Create();
 light->SetRotation(35,35,0);

 //Create a model
 entity1 = Model::Box();
 entity1->SetColor(0.0,0.0,1.0);
 entity1->SetRotation(0,-90,0);

//Create another model to point at the one that goes in circles
 entity2 = Model::Box();
 entity2->SetColor(0.0,1.0,0.0);
 entity2->SetPosition(0,0,2);

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

 //Make the model move in a circle
 entity1->Turn(0,Time::GetSpeed()*0.5,0);
 entity1->Move(0,0,0.1);

//Point this at the moving box when the space key is pressed
if (window->KeyDown(Key::Space))
{
 entity2->Point(entity1,2,Time::GetSpeed()*0.1);
}

 Time::Update();
 world->Update();
 world->Render();
 context->Sync(false);

 return true;
}

Link to comment
Share on other sites

  • 2 weeks later...

I'm not seeing it. This will print the mem usage out in the console. Run it in debug mode:

#include "App.h"
using namespace Leadwerks;
App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
App::~App() { delete world; delete window; }
Entity* entity1 = NULL;
Entity* entity2 = NULL;
bool App::Start()
{
window = Window::Create("",400,100);
context = Context::Create(window);
world = World::Create();
camera = Camera::Create();
camera->Move(0, 1, -3);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);

//Create a model
entity1 = Model::Box();
entity1->SetColor(0.0, 0.0, 1.0);
entity1->SetRotation(0, -90, 0);

//Create another model to point at the one that goes in circles
entity2 = Model::Box();
entity2->SetColor(0.0, 1.0, 0.0);
entity2->SetPosition(0, 0, 2);

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

//Make the model move in a circle
entity1->Turn(0, Time::GetSpeed()*0.5, 0);
entity1->Move(0, 0, 0.1);

//Point this at the moving box when the space key is pressed
if (window->KeyDown(Key::Space))
{
entity2->Point(entity1, 2, Time::GetSpeed()*0.1);
}

Time::Update();
world->Update();
world->Render();

System::Print(System::GetMemoryUsage());

context->Sync(false);

return true;
}

 

 

As objects move around there will be small changes in memory usage as the octree is created and broken, but I don't see anything that looks like a leak.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...