How Ren'Py handles the 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.
Message
Author
User avatar
killdream
Veteran
Posts: 325
Joined: Wed Nov 05, 2008 1:05 pm
Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
Deviantart: robotlolita
Github: robotlolita
Location: World's End (aka Brazil)
Contact:

How Ren'Py handles the memory?

#1 Post by killdream » Sun Apr 19, 2009 8:17 pm

Actually it's a lousy title, sorry i.i

Well, I was playing with the particles factory to create a falling snow effect. Particles should fade over the course of time, and since I couldn't do that with At functions I decided to put a im.alpha to change the alpha in every frame (yes, a lousy workaround as well). It works just perfecly, but it's not much memory effective.

Does Ren'Py caches every result of a im function? (That would explain why memory keeps increasing as long as the particles are on screen) And if it does, is there some way of actually turning this cache function off?

User avatar
Cynebeald
Regular
Posts: 45
Joined: Fri Feb 27, 2009 10:51 am
Projects: Enmaku
Contact:

Re: How Ren'Py handles the memory?

#2 Post by Cynebeald » Tue Apr 21, 2009 7:37 am

From the documentation:
Caching. By default, image manipulators are cached in memory before they are loaded. Supplying the cache=False argument to an image manipulator will prevent this caching. This should only be used when an image manipulator is never used directly (such as by an image statement).

User avatar
Cynebeald
Regular
Posts: 45
Joined: Fri Feb 27, 2009 10:51 am
Projects: Enmaku
Contact:

Re: How Ren'Py handles the memory?

#3 Post by Cynebeald » Tue Apr 21, 2009 7:52 am

On second thought, maybe should NOT disable caching, because renpy would have to apply alpha to each particle every time it is drawn, and that could cause performance problems. How about pre-computing the different faded versions of the particles? This is going to use more memory than not caching at all, but on the other hand it could be smoother than blending particles every time.

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: How Ren'Py handles the memory?

#4 Post by Jake » Tue Apr 21, 2009 9:46 am

Cynebeald wrote:On second thought, maybe should NOT disable caching, because renpy would have to apply alpha to each particle every time it is drawn, and that could cause performance problems.
But then, if you're - say - doing a rotation based on how long the displayable has been displayed, you rapidly run out of memory as Ren'Py caches millions of ever-so-slightly-different result images just on the very unlikely off-chance that it's going to be able to re-use one of them again later.

Serously, the naïve approach to this ran my 2GB Windows machine out of memory in about 2.5 seconds, when I was working with zooming an 800x600 graphic.



(And speaking of gaps in the documentation, since each of the im.* manipulators has its own page, it would be a good idea to mention the cache and rle parameters on those pages - or at least mention that there are other params common to all manipulators which aren't described on that page. I'd just gone straight to the im.FactorZoom page and missed that there was a cache parameter at all, originally.)
Server error: user 'Jake' not found

User avatar
killdream
Veteran
Posts: 325
Joined: Wed Nov 05, 2008 1:05 pm
Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
Deviantart: robotlolita
Github: robotlolita
Location: World's End (aka Brazil)
Contact:

Re: How Ren'Py handles the memory?

#5 Post by killdream » Tue Apr 21, 2009 10:01 am

Hm, yep, I changed it to precompute all possible images in an array in the particles factory, it works very nice since the particles are really small, thanks for the advice ^^

And yeah, I always go to the function index reference too, so I didn't found out about the caching/rle stuff. But well, Ren'Py documentation is a wiki after all, so I think anyone can workaround this in their free-time (guess I'll write some doc examples later)

Hm, and actually SDL can manage some effects in real-time without caching stuff - I used some in my tetris game, they'd work just fine besides the fact of pygame being really high-level (maybe it'll be better when they change to pygame 2.0, implementing SDL gfx would help, but I think using OpenGL would make Ren'Py _really_ better * support to 3d transforms in a 2d enviroment would be nice for lots of effects *)

User avatar
BCS
Eileen-Class Veteran
Posts: 1303
Joined: Mon Sep 19, 2005 2:15 am
Location: Florida
Contact:

Re: How Ren'Py handles the memory?

#6 Post by BCS » Tue Apr 21, 2009 3:28 pm

I wish I could find a tutorial for particles in Ren'Py.... I keep on trying to learn how to use them in Ren'Py, failing miserably, and then use another program to make them and export an image series or some such .... like 10 frames for water, 5 frames for rain behind a window, 8 frames for fire flickering...

The documentation on the factories and what each tuple is leaves me more confused than it did before I even tried to make, say, bubbles or rain.

User avatar
EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: How Ren'Py handles the memory?

#7 Post by EvilDragon » Wed Apr 22, 2009 9:18 am

BCS wrote:The documentation on the factories and what each tuple is leaves me more confused than it did before I even tried to make, say, bubbles or rain.
This.

Until then, SnowBlossom is good enough for snow, rain, leaves, mists, etc. Coupled with randomness and different spline movement per particle (is this even possible?), you can have some really cool effects. For example, snowflakes don't drop horizontally on the ground, they wiggle in all directions before they drop to the floor. I sense that a combination of low-frequency sine and cosine curves (one used for horizontal, one for vertical direction), would give enough wiggleness for that. A random wiggle curve would probably be even better.
Angels of paradise, angels of sacrifice
Please let me be under your wings...

User avatar
PyTom
Ren'Py Creator
Posts: 15423
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How Ren'Py handles the memory?

#8 Post by PyTom » Wed Apr 22, 2009 11:51 am

It's possible with Particles but not SnowBlossom.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
killdream
Veteran
Posts: 325
Joined: Wed Nov 05, 2008 1:05 pm
Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
Deviantart: robotlolita
Github: robotlolita
Location: World's End (aka Brazil)
Contact:

Re: How Ren'Py handles the memory?

#9 Post by killdream » Wed Apr 22, 2009 2:58 pm

Well, actually the only thing you really need is to apply wind's force in the particles (you apply random window force so it looks more real, without sine/cosine based curves that are really not efficient and not needed too), so they seem more real. In my case I needed particles of different sizes (that looks like it have some depth, as particles falling far from the screen will appear smaller than those falling near the screen) and that faded as they felt (I don't remember why I wanted it, though, I already changed the main menu alot .-.).

If someone wants it, I can comment better the code and share it.

This is more or less how the effects look, actually (aside that it falls faster in mine, but the logic is pretty much the same)
http://www.kirupa.com/developer/flash8/snow.htm

User avatar
EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: How Ren'Py handles the memory?

#10 Post by EvilDragon » Wed Apr 22, 2009 5:52 pm

killdream wrote:If someone wants it, I can comment better the code and share it.

This is more or less how the effects look, actually (aside that it falls faster in mine, but the logic is pretty much the same)
http://www.kirupa.com/developer/flash8/snow.htm
Cookbook it?
Angels of paradise, angels of sacrifice
Please let me be under your wings...

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4026
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: How Ren'Py handles the memory?

#11 Post by jack_norton » Thu Apr 23, 2009 4:51 am

Nice effect, yes I think could be a valuable addition to the cookbook.
follow me on Image Image Image Image
computer games

User avatar
killdream
Veteran
Posts: 325
Joined: Wed Nov 05, 2008 1:05 pm
Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
Deviantart: robotlolita
Github: robotlolita
Location: World's End (aka Brazil)
Contact:

Re: How Ren'Py handles the memory?

#12 Post by killdream » Thu Apr 23, 2009 12:43 pm

Cookbook'd =D

I took a while to comment/rewrite the code in a more generic way. Things are pretty much chaotic here, since the dead line for the demo of my first commercial project is comming closer and... there's loooot of work to do i.i (though, I'm not the most doomed one, since I'm doing just programming)

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4026
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: How Ren'Py handles the memory?

#13 Post by jack_norton » Thu Apr 23, 2009 1:46 pm

What game are you making? a normal one or a hentai game? :mrgreen:
follow me on Image Image Image Image
computer games

User avatar
killdream
Veteran
Posts: 325
Joined: Wed Nov 05, 2008 1:05 pm
Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
Deviantart: robotlolita
Github: robotlolita
Location: World's End (aka Brazil)
Contact:

Re: How Ren'Py handles the memory?

#14 Post by killdream » Thu Apr 23, 2009 2:11 pm

jack_norton wrote:What game are you making? a normal one or a hentai game? :mrgreen:
I can't do this kind of games, I'm a christian protestant guy after all. And although I don't mind reading/playing games that can have sexual content if the story is great, I'm not a fan of it myself and wouldn't put it just for fanservice.

The commercial project is an hybrid VN/RPG game. Can't say much about the story and such for now otherwise Ryuno will kill me for sure xD but when we finish the demo I should make a WIP thread here, though.

And, no, the game doesn't have christian/whatever messages in it =D

User avatar
zanaikin
Regular
Posts: 26
Joined: Sun Jul 06, 2008 12:27 am
Projects: TIP
Contact:

Re: How Ren'Py handles the memory?

#15 Post by zanaikin » Thu Apr 30, 2009 1:21 am

Cynebeald wrote:From the documentation:
Caching. By default, image manipulators are cached in memory before they are loaded. Supplying the cache=False argument to an image manipulator will prevent this caching. This should only be used when an image manipulator is never used directly (such as by an image statement).
=O

Can you select to prevent caching for entire UI widgets / layers ? I couldn't find anything about it in the UI functions docs.

Also, is there a way to lower the graphics cache limit ?

Post Reply

Who is online

Users browsing this forum: Bing [Bot]