Showing images and memory

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.
Post Reply
Message
Author
Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Showing images and memory

#1 Post by Ryue » Sat Feb 07, 2015 6:06 am

Due to a post in a demo thread for my dungeon crawler I'm currently trying to find out where some unexpected memory usage could come from. Due to my (bad) experiences with garbage collection in other languages I'm wondering if that could be the cause here (the documentation I found about python garbage collection doesn't tell me how good / efficient it is or how often it is normally run ).

So basically what I'm doing is this

1.) I'm loading images from the disk during initialization
2.) Ingame I'm showing the same image at different locations on screen under different tags (but at the beginning I'm using renpy.scene() before beginnign to draw the images)
3.) I'm waiting until the user cliks on an image button (on a screen) or presses a specific key until I go back to 2.)

I'm NOT using gc.collect or anything.

Seemingly the memory allocation varies quite greatly so the question is can point 2 be the cause for it so that point 2 is triggered multiple times without the memory used in between beeing freed again? (thus using up more and more memory instead of about the same amount?)

User avatar
AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: Showing images and memory

#2 Post by AxemRed » Sat Feb 07, 2015 8:40 am

On my machine, your demo starts at ~720MB internal memory and eventually stabilizes at ~900MB. There are no noticeable garbage collection pauses. In fact, it doesn't seem like any images ever get unloaded.

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: Showing images and memory

#3 Post by Ryue » Sat Feb 07, 2015 9:53 am

the enver get unloaded makes sense in a way as all images are pre loaded but the increase by 180 MB DURING play is something I'm not getting. do you have any idea there? (like I said the way I do things is just those 3 points above)

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

Re: Showing images and memory

#4 Post by nyaatrap » Sat Feb 07, 2015 10:38 am

If you're using renpy.cache_pin, I suggest you better not to use it as possible as you can. In my experience, it likely causes memory issue.
One more advice is use Transform a lot. For example, right side of the screen should be shown with Transform("left_side_image", xzoom=-1), so memory usage will be half. Using smaller textures with Transform zoom is another idea.

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: Showing images and memory

#5 Post by Ryue » Sat Feb 07, 2015 10:43 am

never used renpy.cache_pin . what is that?
will look into the transformations there (maybe I can save loading both right and left side there [need to look how it impacts performance if I do that on the fly]) tnx

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

Re: Showing images and memory

#6 Post by nyaatrap » Sat Feb 07, 2015 11:20 am

Wolf wrote:never used renpy.cache_pin . what is that?
It's a function to load images permanently over config.cache_size. This should be used on only UI images.
the enver get unloaded makes sense in a way as all images are pre loaded but the increase by 180 MB DURING play is something I'm not getting. do you have any idea there? (like I said the way I do things is just those 3 points above)
Ren'py records many data for rollback and some others. It's better to keep at least 200mb free RAM space for it in a complicated program.

Ryue
Miko-Class Veteran
Posts: 745
Joined: Fri Nov 02, 2012 8:41 am
Projects: Red eyes in the darkness
Contact:

Re: Showing images and memory

#7 Post by Ryue » Sat Feb 07, 2015 5:57 pm

Hmm interesting. The game uses 528-576 MB for me. when I put up gc.collect() at the end of each rendering that is reduced to 430-491 MB

Post Reply

Who is online

Users browsing this forum: Google [Bot], Triority