Crash

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
SliiX
Prole
Posts: 12
Joined: Mon Apr 13, 2020 9:04 am

Crash

Post by SliiX »

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 144 times
utils.lua
Just some tools
(630 Bytes) Downloaded 132 times
main.lua
And the main
(921 Bytes) Downloaded 122 times
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Crash

Post by pgimeno »

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.
SliiX
Prole
Posts: 12
Joined: Mon Apr 13, 2020 9:04 am

Re: Crash

Post by SliiX »

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
    
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Crash

Post by pgimeno »

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
    
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.

Removing the call to world:render() does not fix the crash, so that's not the problem.
SliiX
Prole
Posts: 12
Joined: Mon Apr 13, 2020 9:04 am

Re: Crash

Post by SliiX »

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?
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Crash

Post by pgimeno »

SliiX 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?
You need serialization for that. How fast and efficient depends on the serialization code. Take a look at
https://github.com/gvx/bitser for example.
User avatar
AuahDark
Party member
Posts: 107
Joined: Mon Oct 23, 2017 2:34 pm
Location: Indonesia
Contact:

Re: Crash

Post by AuahDark »

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!
SliiX
Prole
Posts: 12
Joined: Mon Apr 13, 2020 9:04 am

Re: Crash

Post by SliiX »

I solved the problem thanks for the support, was really helpful!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 89 guests