DooMAGE Posted December 8, 2016 Share Posted December 8, 2016 Hello guys, I am working on a loading screen, and when I pass a string to the load function call my loading screen the video memory jumps to 300mb+ to 800mb+ Here my code: -- world creation here function LoadingScreen() context:SetBlendMode(Blend.Alpha) local loadingFont = Font:Load("Fonts/arial.ttf",42) context:SetFont(loadingFont) local loadingText = "L O A D I N G . . ." local x = (window:GetWidth() / 2) - (loadingFont:GetTextWidth(loadingText) / 2) local y = (window:GetHeight() / 2) - (loadingFont:GetHeight() / 2) -- Fill screen with black context:SetColor(0, 0, 0) context:DrawRect(0, 0, window:GetWidth(), window:GetHeight()) -- Draw "Loading" text context:SetColor(1, 1, 1) context:DrawText(loadingText, x, y) context:Sync(false) end LoadingScreen() -- map loading here -- inside the main loop if Map:Load("Maps/"..changemapname..".map", "LoadingScreen")==false then return end -- inside the main loop I did something wrong? Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
martyj Posted December 8, 2016 Share Posted December 8, 2016 300 to 800 what? Bytes? Kilobytes? Megabytes? It could just be the memory needed by your map. Game assets are quite large in size. Quote Link to comment Share on other sites More sharing options...
DooMAGE Posted December 9, 2016 Author Share Posted December 9, 2016 When I use the normal Map:Load, the video memory is about 300mb+ , but if I send a string to the load function the video memory goes to over 800mb. It's not about assets. Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
macklebee Posted December 9, 2016 Share Posted December 9, 2016 A leak would imply its continually increasing. The problem is with what you are doing with the hook. hookname: script function name that will be called for each loaded entity in the scene. You are loading the font every time an entity is loaded from your map. Just call the loading screen function separately (and one time) if the map is changed then perform Map:Load(). ... --in the main loops check for the changemapname ... LoadingScreen() if Map:Load("Maps/"..changemapname..".map")==false then return end ... ... 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
DooMAGE Posted December 9, 2016 Author Share Posted December 9, 2016 Thank you I'll look into it Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
macklebee Posted December 9, 2016 Share Posted December 9, 2016 Also, just load the "loading font' once as well. font = context:GetFont() loadingFont = Font:Load("Fonts/arial.ttf",42) loadingText = "L O A D I N G . . ." function LoadingScreen() context:SetBlendMode(Blend.Alpha) context:SetFont(loadingFont) local x = (window:GetWidth() / 2) - (loadingFont:GetTextWidth(loadingText) / 2) local y = (window:GetHeight() / 2) - (loadingFont:GetHeight() / 2) -- Fill screen with black context:SetColor(0, 0, 0) context:DrawRect(0, 0, window:GetWidth(), window:GetHeight()) -- Draw "Loading" text context:SetColor(1, 1, 1) context:DrawText(loadingText, x, y) context:SetFont(font) context:Sync(false) end LoadingScreen() When I do this and what I showed above for changing maps, I get the same memory usage each time I load the same map instead of it increasing each load. EDIT --Actually just load the font separately and one time like shown above and you can still keep the hook function in the Map:Load(). But since you are just drawing a static text/image there's no reason to do this as there is no reason to update per entity being loaded. If you were doing some kind of progress bar or dynamic text, then you would want to use the hook option. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel 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.