Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
kingomar
Prole
Posts: 37
Joined: Mon Mar 17, 2014 8:01 pm

Hello Everybody! Im partially new to Love2d and i almost finished my first game..
However, My game uses alot of Memory! and it's really slow to open.. like when i click on the .love file it causes my computer to freeze and takes more than 10 seconds to start! Moreover, what's even worse, it draw alot of Memory! Over 385k!
Untitled.png (1.79 KiB) Viewed 4797 times
I tried to monitor where all the memory issues is coming from and discovered that the line:

Code: Select all

require "Laboratory"

is causing all the problems.. In that lua file im trying to load like almost 250 images and im not done yet.. i'm loading them without calling a function, just by defining table.. like this as an example:

Code: Select all

Step1[1] = love.graphics.newImage("Resources/Dilution/Step1/1.png")
Step1[2] = love.graphics.newImage("Resources/Dilution/Step1/2.png")
Step1[3] = love.graphics.newImage("Resources/Dilution/Step1/3.png")
Step1[4] = love.graphics.newImage("Resources/Dilution/Step1/4.png")
Step1[5] = love.graphics.newImage("Resources/Dilution/Step1/5.png")
Step1[6] = love.graphics.newImage("Resources/Dilution/Step1/6.png")
Step1[7] = love.graphics.newImage("Resources/Dilution/Step1/7.png")
Step1[8] = love.graphics.newImage("Resources/Dilution/Step1/8.png")
Step1[9] = love.graphics.newImage("Resources/Dilution/Step1/9.png")
Step1[10] = love.graphics.newImage("Resources/Dilution/Step1/10.png")
Step1[11] = love.graphics.newImage("Resources/Dilution/Step1/11.png")
Step1[12] = love.graphics.newImage("Resources/Dilution/Step1/12.png")
Almost 300 line like that... Hehe...
I Considered using Kikito Library(This guy is epic though) loader.. i thought it might help.. but i prefered making sure that it will help before wasting time using it..

What's even worse i'm only half done of adding images and there's still sounds...
I don't want to add love files because i want it to still exclusive until i release it soon enough..
What's the best way to fix this major problem? And is there any way i can lower the memory consumption?

Thanks Guys! You're Epic!

UPDATE: https://www.dropbox.com/s/inlqlae5csogrsz/DEMO.love Love File
Last edited by kingomar on Sun Apr 20, 2014 8:09 pm, edited 2 times in total.
Check out my game:
Jasoco
Inner party member
Posts: 3655
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

How big are these images? If they're huge then of course they'll take a lot of memory.

Also, that entire block of code can be replaced with this simple loop in case you didn't know:

Code: Select all

Step1 = {}
for i = 1, 300 do
Step1[i] = love.graphics.newImage("Resources/Dilution/Step1/" .. i ..  ".png")
end
Change 300 to however many images you have. And if you have more than one step, I suggest making it a multi-dimentional table like so instead:

Code: Select all

Step = {}
for s = 1, numberOfSteps do
Step[s] = {}
for i = 1, 300 do
Step[s][i] = love.graphics.newImage("Resources/Dilution/Step" .. s .. "/" .. i ..  ".png")
end
end
But really, as long as those images aren't huge (What are they? Sprites) then it's better to use one big sheet of images and split it into quads instead of individual images. But if they're supposed to be slides for a sort of video like animation then man, that's a lot of slides.

I mean what exactly are these images?
kingomar
Prole
Posts: 37
Joined: Mon Mar 17, 2014 8:01 pm

Sir i tried your suggestion and the Memory usage got way higher! reached 670k and then love2d gave me the error : "Out Of Memory"

I'm trying to load these images:
http://postimg.org/image/nieq0ioh1/

Each frame is extracted and is getting loaded in my game.. every image weights like 10kb in size..
Any Solution?
Check out my game:
Party member
Posts: 513
Joined: Fri May 03, 2013 6:42 pm
Location: Germany

kingomar
Prole
Posts: 37
Joined: Mon Mar 17, 2014 8:01 pm

Check out my game:
kingomar
Prole
Posts: 37
Joined: Mon Mar 17, 2014 8:01 pm

Is the library loader is a nice solution?
Or can i require a .lua file when needed?? like when i need to access the GameState where it requires these images to be loaded..
Check out my game:
Party member
Posts: 105
Joined: Fri Sep 03, 2010 12:39 pm
Contact:

This project is way too big to analyse without proper indentation. Please indent your code and reupload and you might get better help.
SneakySnake
Citizen
Posts: 94
Joined: Fri May 31, 2013 2:01 pm
Contact:

There is only so much you can do about loading so many - quite large - images at once.
If the memory usage is a problem, you should try to only load the resources that are necessary at a time, instead of loading everything at the beginning.
kingomar
Prole
Posts: 37
Joined: Mon Mar 17, 2014 8:01 pm

I used loader library and it works like a charm.. But still got the same Memory usage... However i was wondering.. If i destroy the tables where my images are contained.. Will the high usage of memory will still occur? Thanks
Check out my game: