Jump to content

Recommended Posts

Posted

Tried to reproduce render issue, but must likely related.

RAM and VRAM usage increase with every "load" despite clearing scene before every time (and using instance).

After dozen times it's 4.1 Gb ram, on first was only 1.4 Gb.

 

#include "Leadwerks.h"
#include "ComponentSystem.h"
#include "Encryption.h"

using namespace Leadwerks;

int main(int argc, const char* argv[]) {
    RegisterComponents();
    auto displays = GetDisplays();
    auto window = CreateWindow("Leadwerks", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto framebuffer = CreateFramebuffer(window);
    auto world = CreateWorld();
    auto light = CreateBoxLight(world);
    light->SetRotation(45, 35, 0);
    light->SetRange(-10, 10);
    light->SetColor(2);

    auto box = CreateBoxBrush(world, 1,1, 1);
    box->SetScale(2);
    box->SetColor(0, 0, 1);

    auto scene = CreateScene();
    int index = 0;
    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {
        if (window->KeyHit(KEY_SPACE)) {
            Print("Before Load");
            window->SetText("Loading");
            scene.reset();
            scene = CreateScene();
            for (int i = 0; i < 35000; i++) {
                auto inst = box->Instantiate(world);
                inst->SetHidden(true);
                inst->SetPosition(Random(10000), Random(10000), Random(10000));
                scene->AddEntity(inst);
            }
            auto camera = CreateCamera(world);
            camera->SetClearColor(0.125);
            camera->SetPosition(0, 0, -4);
            scene->AddEntity(camera);
            index++;
            window->SetText("Done " + String(index));
            Print("After Load " + String(index));

        }
        box->Turn(1);
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

  • Like 1

Check out Slipgate Tactics demo, which is made with Ultra Engine/Leadwerks 5:

https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/

Posted

I simplified the code a bit.

auto displays = GetDisplays();
auto window = CreateWindow("Leadwerks", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
auto framebuffer = CreateFramebuffer(window);
auto world = CreateWorld();
        
//auto box = CreateBox(world);
auto box = CreateBoxBrush(world, 1, 1, 1);
box->SetCollider(NULL);
box->SetPhysicsMode(PHYSICS_DISABLED);

auto camera = CreateCamera(world);
camera->SetPosition(0, 0, -4);
        
std::vector<shared_ptr<Entity> > entities;
auto tm = Millisecs();

//Main loop
while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {  
    auto now = Millisecs();
    if (now > tm + 5000)
    {
        entities.clear();
          window->SetText(GetMemoryUsage());
        for (int n = 0; n < 1000; ++n)
        {
            auto inst = box->Instantiate(world);
            inst->SetPosition(Random(-100, 100), Random(-100, 100), Random(-100, 100));
            entities.push_back(inst);
        }
        tm = now;
    }
             
    //Cleanup
    FlushEvents();// clear event queue
    world->GetEntities();// cleans entity list of weak pointers

    world->Update();
    world->Render(framebuffer);
}
return 0;

It looks like the leak only occurs when a brush is used.

image.thumb.png.b902a153c0079524cfdb4adbe710aa52.png

When a box model is created, the memory usage looks flat.

image.png.07c55bd11605666a7d38d28a913a155b.png

 

Let's build cool stuff and have fun. :)

Posted

In the current build, the original example above provides unclear results. If it just a really bad memory leak, I would expect the RAM usage to increase by the same amount each time. Instead we see it either levelling off or slowing down.

image.thumb.png.390813a792afdf8dafc210550bde78cf.png

It is possible this could be a combination of the system reserving more RAM, in combination with a smaller mem leak, but keep in mind the example is creating and deleting 35,000 entities each time. The change I am seeing works out to 1.2 KB per entity, which is something to be fixed, but also is probably not a major immediate problem for anyone.

  • Like 1

Let's build cool stuff and have fun. :)

  • 2 months later...
  • 2 weeks later...
Posted

This bug is ruining my game. (2)

(I will send a reminder message once a week until this issue is resolved.)
(If the engine exits early access before this serious bug is fixed, it means that this error is either not taken seriously or has been forgotten.)


image.png.22be393e9b5993ae889cc799e975df56.png


https://youtu.be/8yncYDSF58E


(This is an old video, but this bug is more noticeable in my game right now. When I exit and re-enter the main menu three times, I experience significant fps drops.)

Posted

Thank you, but please do not bump threads. I can easily see all unsolved threads at all times with the filtering menu in the top-right.

Let's build cool stuff and have fun. :)

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.

×
×
  • Create New...