Jump to content

[INCOMPLETE] Probable Character Controller Memory Leak


tjheldna
 Share

Recommended Posts

In all my projects tested memory was increasing (viewed in the resource manager under working set) until finally you get a lua our of memory error and the game crashes (takes ages). This was common between all my projects C++.

 

Created a fresh project and the 'working set' field stays static, changed that default cube to be a character controller and memory starts going up and continues to in the 'working set' field.

 

Cheers

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

Make a copy of your project, and try the beta, Josh had done some work on it and found 3 memory leaks. I don't know if this has moved to the release version yet. I say make a copy because if you run the beta the version number within your map may get changed and you will need to wait for that beta to become the release, if you want to go back to the release version, or get a copy of the map from the backup folder.

 

But its far easier to make a backup of the project.

Link to comment
Share on other sites

  • 2 weeks later...

It looks completely solid to me:

#include "App.h"

using namespace Leadwerks;

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

App::~App() { delete world; delete window; }

Vec3 camerarotation;
bool freelookmode=true;

bool App::Start()
{
   //Initialize Steamworks (optional)
   /*if (!Steamworks::Initialize())
   {
       System::Print("Error: Failed to initialize Steam.");
       return false;
   }*/

   //Create a window
   window = Leadwerks::Window::Create("memtest");

   //Create a context
   context = Context::Create(window);

   //Create a world
   world = World::Create();

   //Create a camera
   camera = Camera::Create();
   camera->Move(0,2,-5);

   //Hide the mouse cursor
   window->HideMouse();

   std::string mapname = System::GetProperty("map","Maps/start.map");
   Map::Load(mapname);

   Model* box = Model::Box();
   box->SetPhysicsMode(Entity::CharacterPhysics);
   box->SetMass(10);
   box->SetPosition(0,5,0);

   //Move the mouse to the center of the screen
   window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);

   return true;
}

bool App::Loop()
{
   //Close the window to end the program
   if (window->Closed()) return false;

   //Press escape to end freelook mode
   if (window->KeyHit(Key::Escape))
   {
       if (!freelookmode) return false;
       freelookmode=false;
       window->ShowMouse();
   }

   if (freelookmode)
   {
       //Keyboard movement
       float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Leadwerks::Time::GetSpeed() * 0.05;
       float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Leadwerks::Time::GetSpeed() * 0.05;
       camera->Move(strafe,0,move);

       //Get the mouse movement
       float sx = context->GetWidth()/2;
       float sy = context->GetHeight()/2;
       Vec3 mouseposition = window->GetMousePosition();
       float dx = mouseposition.x - sx;
       float dy = mouseposition.y - sy;

       //Adjust and set the camera rotation
       camerarotation.x += dy / 10.0;
       camerarotation.y += dx / 10.0;
       camera->SetRotation(camerarotation);

       //Move the mouse to the center of the screen
       window->SetMousePosition(sx,sy);
   }

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

   context->SetBlendMode(Blend::Alpha);
   context->DrawText(String(System::GetMemoryUsage()),2,2);

   context->Sync(false);

   return true;
}

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

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...