Crash
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Crash
So, I am working on an infinite map generation thing for a 2d game and I have it about half way done, but I was bug testing and decided to go super far out and see if it affects performance. Anyways, once I got to about 42,000 (8 tile x 8 tile ) chunks with (64 pixel x 64 pixel) tiles in each chunk and the game program just turns off completely? Anyone know what could be the cause of this?
- Attachments
-
- engine.lua
- This is where all of the generation happens
- (6.05 KiB) Downloaded 159 times
-
- utils.lua
- Just some tools
- (630 Bytes) Downloaded 137 times
-
- main.lua
- And the main
- (921 Bytes) Downloaded 126 times
Re: Crash
It appears that you're reaching LuaJIT's memory limit. I've tried with LuaJIT-2.1.0-beta3 with GC64 enabled and it doesn't crash.
Re: Crash
Alright cool thanks! Is there a way to not store the map data in memory? Or, do I have to use luaJIT 2.1.0?
Edit:
So I did some research and it appears I made a weird mistake in the code below:
Edit:
So I did some research and it appears I made a weird mistake in the code below:
Code: Select all
local chunks = {}
local loaded = {}
function render()
-- this is supposed to reset the loaded table
-- but apparently this does not clear it from memory?
loaded = {}
for i = 1,#chunks do
-- bunch of if statements
loaded[#loaded+1] = chunks[i]
end
end
function love.update()
render()
end
Re: Crash
You can free up some map data from memory. Chunk-based programs (e.g. Minetest) usually use a disk database to store generated chunks on and free them from memory.SliiX wrote: ↑Mon Apr 13, 2020 10:47 pm Alright cool thanks! Is there a way to not store the map data in memory? Or, do I have to use luaJIT 2.1.0?
Edit:
So I did some research and it appears I made a weird mistake in the code below:
Code: Select all
local chunks = {} local loaded = {} function render() -- this is supposed to reset the loaded table -- but apparently this does not clear it from memory? loaded = {} for i = 1,#chunks do -- bunch of if statements loaded[#loaded+1] = chunks[i] end end function love.update() render() end
Removing the call to world:render() does not fix the crash, so that's not the problem.
Re: Crash
The disk thing is a good idea and is gonna need to me implemented anyways, I went ahead and made a much smaller and quicker and just generally less messy version of this and its working a lot better. With that being said, is there a fast and efficient way of storing tables on disk?
Re: Crash
You need serialization for that. How fast and efficient depends on the serialization code. Take a look atSliiX wrote: ↑Wed Apr 15, 2020 12:32 am The disk thing is a good idea and is gonna need to me implemented anyways, I went ahead and made a much smaller and quicker and just generally less messy version of this and its working a lot better. With that being said, is there a fast and efficient way of storing tables on disk?
https://github.com/gvx/bitser for example.
Re: Crash
You can workaround the memory limit by using love.data.newByteData and FFI then store your data there. However, depending on how you structure the game, it may be not possible.
Profile. Do you encounter crashes in LÖVE Android and wanna send me logcats? Please hit me up in LÖVE Discord and send the full logcat file!
Who is online
Users browsing this forum: No registered users and 2 guests