Yue Posted July 31, 2023 Share Posted July 31, 2023 When I set Time::Pause(); it starts to increase the memory usage drastically, both in script and in c++, is that a normal memory leak? Quote Link to comment Share on other sites More sharing options...
Josh Posted July 31, 2023 Share Posted July 31, 2023 Does the increased memory get released when you resume the time? Quote 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 More sharing options...
Yue Posted July 31, 2023 Author Share Posted July 31, 2023 Memory remains where it was last time. For example, if the game is paused, it goes up in value, but when you continue the game, it stays at the last value. If it was for example in 100, it goes up continuously until I continue the game, and it remains in for example in 500, if I pause it again it continues going up. Quote Link to comment Share on other sites More sharing options...
Yue Posted July 31, 2023 Author Share Posted July 31, 2023 Quote Link to comment Share on other sites More sharing options...
Yue Posted August 2, 2023 Author Share Posted August 2, 2023 Someone help me, is this a memory leak? Quote Link to comment Share on other sites More sharing options...
Josh Posted August 3, 2023 Share Posted August 3, 2023 Comment out parts of your code to find out what part is causing it. If the engine memory goes up without your code doing anything, then it would indicate a leak in the engine, but that's probably not the case. It's also possible for memory usage to go up sometimes but then stabilize. This can happen when an object travels into an area of the world that does not have any octree structure initialized yet for that area or other data initialization things. Quote 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 More sharing options...
Alienhead Posted August 3, 2023 Share Posted August 3, 2023 I generally put a manual GC in my loop, on a 30 second timer I call "collectgarbage()" .. but looking at your problem this may not help you as you have the symptoms of a genuine memory leak caused by some runaway code. Are you by chance using any Point Lights set to Static only ? Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Yue Posted August 3, 2023 Author Share Posted August 3, 2023 I only have a terrain, a directional light, the character and the vehicle. The code is structured in the Input object, Player object, Rover object, Windows object. But the strange thing is that it only happens when I pause the game and show the menu. Time::Pause(). //Code Main. #include "App.h" using namespace Leadwerks; int main() { CWindow window("App Title", 1280, 720); CWorld menu; menu.LoadMap("Menu.map"); CInput input; CRover rover(input); CGUI gui(input); CPlayer player(input,rover,gui); // Bucle principal. while (!window.GetClosed()) { if (input.GetKeyDown(Key::H)) { return 0; } Time::Update(); gui.Update(); menu.Update(); menu.Render(); player.Update(); rover.Update(); window.ShowDebugInfo(); player.DrawHand(window.GetContext()); window.Update(false); } return 0; } GUI Show HIde Menu. #include "CGUI.h" using namespace Leadwerks; // Constructor. CGUI::CGUI(CInput& input) :input(input) { window = Window::GetCurrent(); context = Context::GetCurrent(); gui = GUI::Create(context); base = gui->GetBase(); StartHUD(); StartMenu(); show = 0; } void CGUI::StartHUD() { Widget* pnlHud = Widget::Panel(window->GetWidth() - 230, 10, 200, 100, base); } void CGUI::StartMenu() { pnlMenu = Widget::Panel(window->GetWidth()/2-250, window->GetHeight()-150, 500, 75, base); // Butons. btnStart = Widget::Button("START", 10, 15, 150, 50, pnlMenu); btnOptions = Widget::Button("OPTIONS", pnlMenu->GetSize(true).x/2-75,15,150,50,pnlMenu); btnExit = Widget::Button("EXIT", pnlMenu->GetSize(true).x -160, 15, 150, 50, pnlMenu); } void CGUI::HideMenuStart() { pnlMenu->Hide(); } void CGUI::ShowMenuStart() { pnlMenu->Show(); } void CGUI::Update() { HideMenuStart(); if (show) { ShowMenuStart(); Time::Pause(); } else { HideMenuStart(); Time::Resume(); } if (input.GetKeyHit(Key::Escape)) { show = 1 - show; } } bool CGUI::GetShow() { return(show); } Quote Link to comment Share on other sites More sharing options...
Yue Posted August 3, 2023 Author Share Posted August 3, 2023 void CGUI::Update() { //HideMenuStart(); << Solved temporal. if (show) { ShowMenuStart(); Time::Pause(); } else { HideMenuStart(); Time::Resume(); } if (input.GetKeyHit(Key::Escape)) { show = 1 - show; } } This partially solves the problem. When I uncomment that line of code it no longer uploads the memory when the game is paused. What happens now is that it goes up a little, for each time I make visible the start menu of the three buttons, the memory usage in C++ and in Script goes up. If someone has any idea why this happens I would appreciate it, or if it is something normal. Quote Link to comment Share on other sites More sharing options...
Alienhead Posted August 3, 2023 Share Posted August 3, 2023 Try calling collectgarbage(), right after you resume the time. See if it returns to the value it was at when you called a time:pause. HideMenuStart(); Time::Resume(); collectgarbage(); It sorta looks like to me you continuously calling ShowMenuStart(); Time::Pause(); Is ShowMenuStart() loading or creating anything each time it's called? 1 Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Yue Posted August 4, 2023 Author Share Posted August 4, 2023 8 hours ago, Alienhead said: Try calling collectgarbage(), right after you resume the time. See if it returns to the value it was at when you called a time:pause. HideMenuStart(); Time::Resume(); collectgarbage(); It sorta looks like to me you continuously calling ShowMenuStart(); Time::Pause(); Is ShowMenuStart() loading or creating anything each time it's called? o.O?? 1>------ Operación Compilar iniciada: proyecto: AstrocucoX, configuración: Release Win32 ------ 1>cl : Línea de comandos warning D9035: La opción 'Gm' está desusada y se quitará en próximas versiones 1>cl : Línea de comandos warning D9030: '/Gm' es incompatible con el multiprocesamiento; se omitirá el modificador /MP 1>CGUI.cpp 1>f:\leadwerks\projects\astrocucox\source\cgui.cpp(51): error C3861: 'collectgarbage': no se encontró el identificador 1>Generando código... 1>Compilando... 1>CInput.cpp 1>Generando código... 1>Omitiendo... (no se detectaron cambios relevantes) 1>main.cpp 1>CWorld.cpp 1>CWindow.cpp 1>CRover.cpp 1>CPlayer.cpp 1>Compilación del proyecto "AstrocucoX.vcxproj" terminada -- ERROR. ========== Compilar: 0 correctos, 1 incorrectos, 0 actualizados, 0 omitidos ========== Quote Link to comment Share on other sites More sharing options...
Alienhead Posted August 4, 2023 Share Posted August 4, 2023 Aggressive settings : collectgarbage("setpause",100); collectgarbage("setstepmul", 100); collectgarbage(); Ooo sorry, garbage collection is LUA, not C++ 1 Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Yue Posted August 4, 2023 Author Share Posted August 4, 2023 I don't understand the visual studio c++ compiler tells me that there is no such garbage collection function. Quote Link to comment Share on other sites More sharing options...
Yue Posted August 4, 2023 Author Share Posted August 4, 2023 At this point I don't know what to do, because it happens when I show the menu and pause the application. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted August 4, 2023 Share Posted August 4, 2023 I re-call this issue ages ago when my project was in Leadwerks. I reckon it's a bug but you can try this in C++. I can't remember if you can even call this function like this, but give it a go and see what happens. System::CollectGarbage(); 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted August 4, 2023 Author Share Posted August 4, 2023 2 minutes ago, SpiderPig said: I re-call this issue ages ago when my project was in Leadwerks. I reckon it's a bug but you can try this in C++. I can't remember if you can even call this function like this, but give it a go and see what happens. System::CollectGarbage(); void CGUI::Update() { pnlMenu->Show(); // Memory usage goes up uncontrollably. if (input.GetKeyHit(Key::Escape)) { show = 1 - show; } if (show) { pnlMenu->Show(); Time::Pause(); } if(!show) { pnlMenu->Hide(); Time::Resume(); } } Nothing happens, the memory keeps going up. I have identified the one that causes the problem, it is when I try to display the panel that contains my three start menu buttons. Every time I show it the memory usage goes up, if I put inside the method it starts to go up uncontrolled. So how do I confirm that if it is a bug, by hiding the whole Gui I don't have that problem. Gui->Hide(); No problem. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted August 4, 2023 Share Posted August 4, 2023 You can confirm it's a bug by making a simple application and posting the code in bug reports to see what Josh says about it. Quote Link to comment Share on other sites More sharing options...
Solution Yue Posted August 4, 2023 Author Solution Share Posted August 4, 2023 I don't think Josh has time for this now, nor does he think he might be interested in it, the result is video I have in this thread, the memory goes up unchecked. The solution from my side is to create a GUI for each particular panel, menu, options etc. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted August 4, 2023 Share Posted August 4, 2023 Yes he's focused on Ultra right now. If you can work around it, that might be best for now. Quote Link to comment Share on other sites More sharing options...
Yue Posted August 6, 2023 Author Share Posted August 6, 2023 On 8/3/2023 at 8:53 PM, SpiderPig said: Yes he's focused on Ultra right now. If you can work around it, that might be best for now. --Create a window window = Window:Create() context = Context:Create(window) world = World:Create() local camera = Camera:Create() camera:Move(0,0,-3) local light = DirectionalLight:Create() light:SetRotation(35,35,0) model = Model:Box() model:SetColor(0.0,0.0,1.0) local gui = GUI:Create(context) local base = gui:GetBase() base:SetScript("Scripts/GUI/Panel.lua") base:SetObject("backgroundcolor",Vec4(0,0,0,0.1)) pnl = Widget:Panel(300,100,200,200,base) cam = Camera:Create() while true do if window:Closed() or window:KeyHit(Key.Escape) then return false end Time:Pause() pnl:Hide() model:Turn(0,Time:GetSpeed(),0); Time:Update() world:Update() world:Render() context:DrawStats(10, 10) context:Sync(false) collectgarbage() end This is a simple example, where the memory goes up. Lua Script. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted August 6, 2023 Share Posted August 6, 2023 I just ran your example above and after about one second the memory usage is perfectly stable. 1 Quote 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 More sharing options...
Josh Posted August 6, 2023 Share Posted August 6, 2023 I'm using the default branch, not the beta build. Quote 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 More sharing options...
Yue Posted August 6, 2023 Author Share Posted August 6, 2023 6 minutes ago, Josh said: I'm using the default branch, not the beta build. https://www.ultraengine.com/community/applications/core/interface/file/attachment.php?id=19023&key=ed9d8c7437710a1384bbc3b62955f7fd AstrocucoX.rarI don't know what I'm doing wrong, see this is the example, when I press the escape key, everything goes up in ram memory usage in an uncontrolled way. Quote Link to comment Share on other sites More sharing options...
Alienhead Posted August 7, 2023 Share Posted August 7, 2023 Works as it should on my system, no memory increase when i Pause. 1 Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
SpiderPig Posted August 7, 2023 Share Posted August 7, 2023 Downloaded and tested and I do see memory increase when paused. Script memory goes up pretty fast. Confirmed with task manager open too. It's a few MB a minute. I wonder what it could be if @Alienhead did not see it on his machine. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.