Memory management?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
ktalkimist
Veteran
Posts: 216
Joined: Fri Oct 19, 2012 10:28 pm
Contact:

Memory management?

#1 Post by ktalkimist »

Is there a way to optimize memory? We've found that our game eats a lot of memory even when you're not doing anything. It would start at 400MB and reach nearly 1.5GB memory consumption by simply moving from one screen to another and talking to people.

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Memory management?

#2 Post by nyaatrap »

Did you update ren'py?
It's a bug before 6.16.3.

User avatar
ktalkimist
Veteran
Posts: 216
Joined: Fri Oct 19, 2012 10:28 pm
Contact:

Re: Memory management?

#3 Post by ktalkimist »

Will it fix the problem for distribution builds? We never really upgraded from 6.16.1. :P

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Memory management?

#4 Post by xela »

It will if you build them from 6.17.x...
Like what we're doing? Support us at:
Image

User avatar
ktalkimist
Veteran
Posts: 216
Joined: Fri Oct 19, 2012 10:28 pm
Contact:

Re: Memory management?

#5 Post by ktalkimist »

xela wrote:It will if you build them from 6.17.x...
Tried and we still have the same problem. Same memory consumption, but now it goes up only when you interact with the environment or enter a new area. Once you leave a memory-intensive area, memory consumption doesn't go down. Is there any way to remedy this without downscaling everything?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Memory management?

#6 Post by xela »

I've thoroughly tested several memory leaks/overflows in a fairly complex game, so far it's always been not fully thought through/bad programming on my part. There is a good chance there is a flaw in yours as well...
Like what we're doing? Support us at:
Image

User avatar
ktalkimist
Veteran
Posts: 216
Joined: Fri Oct 19, 2012 10:28 pm
Contact:

Re: Memory management?

#7 Post by ktalkimist »

Is this within Ren'py? Any tips? Our programmer isn't quite sure yet how to go about memory management on Ren'py. :(

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Memory management?

#8 Post by xela »

Obviously within Ren'Py... Once I've cached actual images (as displayable) instead of imagepaths that caused out of memory errors after playing for some time. At other time I didn't hide images or screens that were called from python with random tags, that resulted in something similar.

There is nothing you can do to "manage" memory in Ren'Py, other then running free memory function or possibly disabling part of functionality/using simpler resources. Python doesn't offer much in controlling allocated memory either... Basically the rule of a thumb should be that if you have memory leaks/overflows on a Ren'Py version where others have none, the fault lies somewhere in your code or misusing/misunderstanding Ren'Py somehow (basically the same thing).

There isn't much advice to be given without access to the code that may be at fault I am afraid.
Like what we're doing? Support us at:
Image

User avatar
ktalkimist
Veteran
Posts: 216
Joined: Fri Oct 19, 2012 10:28 pm
Contact:

Re: Memory management?

#9 Post by ktalkimist »

Yeah, we're considering downscaling the remaining resources as a last resort (already optimized the sprites). We use imagepaths and we do hide images/screens. Gonna have our programmer post actual code in a few minutes. Not sure what we're doing wrong. One issue we want to address is memory consumption that doesn't go down after leaving a memory-intensive area.

Thanks for the cool input!

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Memory management?

#10 Post by Asceai »

ktalkimist wrote:One issue we want to address is memory consumption that doesn't go down after leaving a memory-intensive area.
I don't think that's an issue, unless the increases are cumulative (in which case it really is leaking memory). Plenty of other apps do the same thing.

The only thing that really matters is that peak usage, because the user might not have enough memory for that (particularly under Android) - average usage doesn't really matter when it comes to memory.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Memory management?

#11 Post by xela »

I didn't actually suggest downscaling of resources to fix your problem. It's one way of lowering memory consumption but your could have a game with access to 100 000 images and it still might use below 250Mb of memory as long as you don't load to much of the resources simultaneously.
Like what we're doing? Support us at:
Image

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Memory management?

#12 Post by Asceai »

One good way of lowering memory usage is to significantly cut down the image cache.

You will pay for this in performance, but it might not be a problem for your game.

config.image_cache_size = 2
or
config.image_cache_size = 1

This can have a serious impact if your game has a high logical resolution (config.screen_width/height) - but you might be best off not touching it if the change in memory usage is unimpressive, because it will severely impact ren'py's ability to do work in the background making your game run smoothly.

User avatar
ktalkimist
Veteran
Posts: 216
Joined: Fri Oct 19, 2012 10:28 pm
Contact:

Re: Memory management?

#13 Post by ktalkimist »

Asceai wrote:
ktalkimist wrote:One issue we want to address is memory consumption that doesn't go down after leaving a memory-intensive area.
I don't think that's an issue, unless the increases are cumulative (in which case it really is leaking memory). Plenty of other apps do the same thing.

The only thing that really matters is that peak usage, because the user might not have enough memory for that (particularly under Android) - average usage doesn't really matter when it comes to memory.
Alright, we really have to lower both average and peak then, I think. Because it peaks at around 1.4GB and averages at 1GB after that, which might be too much for some people.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Memory management?

#14 Post by xela »

ktalkimist wrote:
Asceai wrote:
ktalkimist wrote:One issue we want to address is memory consumption that doesn't go down after leaving a memory-intensive area.
I don't think that's an issue, unless the increases are cumulative (in which case it really is leaking memory). Plenty of other apps do the same thing.

The only thing that really matters is that peak usage, because the user might not have enough memory for that (particularly under Android) - average usage doesn't really matter when it comes to memory.
Alright, we really have to lower both average and peak then, I think. Because it peaks at around 1.4GB and averages at 1GB after that, which might be too much for some people.
My game crashes at 1.4GB... But only way I got there in the first place was a bad approach to caching images that were drawn from a random pool to be displayed on the screen (screen language).

Edit:
I don't think you can reach that during normal operations unless you're using Ren'Py for something seriously insane :)

My guess would be is that you're NOT caching paths somewhere but actually caching displayable instead. This behavior is TOO similar to what happened to me... 1GB = Normal operation, 1.3 - 1.5(crash) on the peak. Now same game runs at below 0.25 GB at all times (testing with 1125 very advanced (logically) characters and 20 000 images loaded into custom database class).
Like what we're doing? Support us at:
Image

User avatar
AlfieMachica123
Regular
Posts: 56
Joined: Sun Jun 30, 2013 10:15 pm
Contact:

Re: Memory management?

#15 Post by AlfieMachica123 »

am sorry, but am a dumb programmer, really

but can you explain (even just a little bit) what does "caching paths" and "caching displayable" mean,


heres what is happening
we have two places, each has a background image(ATL) one having 2(frames) and the other having 10(frames)
about what i am talking about, this is how i roll(code) with it,

Code: Select all

label dubidumbdumb:
    if qmu_dubidumbdumb:
        scene BGdubidumbdumb with Dissolve(0.3) ##background image(ATL)
        $ qmu_dubidumbdumb = False
    call screen SCdubidumbdumb ##screen set of imagebuttons
    $ rst1 = _return
    if rst1 == "mo1":
        dumb_person "let's go to dubidumbdumb2"
        $ qmu_dubidumbdumb = True
        jump dubidumbdumb2
    elif rst1 == "mo2":
        dumb_person "let's go to dubidumbdumb3"
        $ qmu_dubidumbdumb = True
        jump dubidumbdumb3
    else:
        dumb_person "oops, i poked [rst1]"
        dumb_person "what shoud i do with [rst1]?"

    jump dubidumbdumb
let's just say that this is the ATL for the background image:

Code: Select all

init:
    python:
        place_of_BGdubidumbdumb = "dubidumbdumb/folder/bg/"
image BGdubidumbdumb:
    (place_of_BGdubidumbdumb + "1.png") ##1920 x 1080 jpg picture
    5.00
    (place_of_BGdubidumbdumb + "2.png" ##same size jpg picture
    5.00
    repeat
so uhmm, can i ask, where does this "caching paths" or this "caching displayable" come in
how do i do this the other way around?

anyway, thanks for every suggestions and comments, ^^

Post Reply

Who is online

Users browsing this forum: No registered users