Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Wed May 22, 2013 8:27 am

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: rollback memory leak ?
PostPosted: Sat Mar 24, 2012 1:21 pm 
Lemma-Class Veteran
User avatar

Joined: Mon Jul 21, 2008 5:41 pm
Posts: 3400
Projects: Planet Stronghold: Warzone, Loren The Amazon Princess, Queen Of Thieves, DIM, Undead Lily, and more...
We've encountered another problem while coding Loren RPG. I noticed using windows resource monitor that every turn of the battle, the memory was increasing. For example at beginning of battle the process renpy.exe would occupy 170mb, and at the end of it would be 280mb!! :shock:
So I've asked Anima who is coding it (since I really don't understand much of python Classes and such) and he showed me this graph:
Attachment:
chain.png
chain.png [ 39.38 KiB | Viewed 279 times ]

I copy paste his words because while I got the general meaning, I wouldn't know how to write in another way:
Quote:
That's the fault of the rollback feature. Please take a look at the
chain.png in the dropbox. The defend skill was used in the first and
second round, but are still there in the sixth. You can see that while
we can no longer reach it trough the combat object, it's still reachable
trough the rollbacklog and therefore not garbage collected.
That's does not only go for our objects, there are over a thousand
objects retained trough rollback every turn.


We tried using some tricks like setting:
config.hard_rollback_limit = 0
to disable it, but the object access graph was still the same even after we used that command.

So the question is: there's a way to solve this ? I believe is a Ren'Py bug? or we're doing something wrong? Thanks

edit: coder said it's not really a bug, but how the rollback works. Still there should be a way to "clear" the object that are in the rollback ?

_________________
follow me on Image Image Image Image
computer games


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 3:22 pm 
Ren'Py Creator
User avatar

Joined: Mon Feb 02, 2004 10:58 am
Posts: 10774
Location: Kings Park, NY
Completed: Moonlight Walks
Projects: Ren'Py
I think the problem is that if you do too much allocation in Python code without returning to Ren'Py code, Ren'Py will never tick the RollbackLog forward, and you can get this problem. Although I don't know your code, chances are that you have a Python while loop as your main loop. Replace that with a Ren'Py while loop as the main loop, and things should start working.

_________________
Another Old-Fashioned Bishoujo Gamer
Supporting creators since 2004; Code > Drama
(When was the last time you backed up your game?)
"It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face in marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming" - Theodore Roosevelt


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 3:41 pm 
Veteran
User avatar

Joined: Wed Nov 18, 2009 11:17 am
Posts: 359
Location: Germany
Completed: Loren
Projects: PS2
No we use a Ren'Py while loop. It looks like Jack got a better behavior with using a label/jump label construct instead of a while loop.
As an experiment I also tried a explicit counting loop to trick the rollback log, but it only accelerated the memory growth at an alarming rate.

It looks to me like a problem with loops and the rollback log in general, or that $ python lines are not counted.
I'll see if we get a somewhat stable memory situation with the label/jump combo.

Edit: The memory usage stabilizes pretty well and fast with the label/jump combination. There might be a problem with rollback log and while loops.

_________________
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase II


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 3:55 pm 
Lemma-Class Veteran
User avatar

Joined: Mon Jul 21, 2008 5:41 pm
Posts: 3400
Projects: Planet Stronghold: Warzone, Loren The Amazon Princess, Queen Of Thieves, DIM, Undead Lily, and more...
Yes the good old label/jump label loop seems to have if not solved the issue completely, surely reduced the memory usage by a lot (I played a few test battles and I don't see the memory skyrocket anymore like before) 8) Thanks

_________________
follow me on Image Image Image Image
computer games


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 4:03 pm 
Ren'Py Creator
User avatar

Joined: Mon Feb 02, 2004 10:58 am
Posts: 10774
Location: Kings Park, NY
Completed: Moonlight Walks
Projects: Ren'Py
Hm... can you put together a short demo of the problem? (Ideally, something where I can just click and see it.) The Ren'Py while loop really should advance the rollback log.

_________________
Another Old-Fashioned Bishoujo Gamer
Supporting creators since 2004; Code > Drama
(When was the last time you backed up your game?)
"It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face in marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming" - Theodore Roosevelt


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 4:16 pm 
Lemma-Class Veteran
User avatar

Joined: Mon Jul 21, 2008 5:41 pm
Posts: 3400
Projects: Planet Stronghold: Warzone, Loren The Amazon Princess, Queen Of Thieves, DIM, Undead Lily, and more...
Ok will try to put a small demo together tomorrow (now is late and worked all day!) :)

_________________
follow me on Image Image Image Image
computer games


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 4:26 pm 
Ren'Py Creator
User avatar

Joined: Mon Feb 02, 2004 10:58 am
Posts: 10774
Location: Kings Park, NY
Completed: Moonlight Walks
Projects: Ren'Py
Please do so early. I want to get 6.13.10 out ASAP.

_________________
Another Old-Fashioned Bishoujo Gamer
Supporting creators since 2004; Code > Drama
(When was the last time you backed up your game?)
"It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face in marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming" - Theodore Roosevelt


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 4:30 pm 
Lemma-Class Veteran
User avatar

Joined: Mon Jul 21, 2008 5:41 pm
Posts: 3400
Projects: Planet Stronghold: Warzone, Loren The Amazon Princess, Queen Of Thieves, DIM, Undead Lily, and more...
The main problem is to "reduce" the game code to a small demo - since it's part of a big set of classes written by Anima and I'm not 100% sure how to reduce it (I would just try to cut out all the stuff around the combat class but then it could crash)... maybe he can be quicker than me :D

_________________
follow me on Image Image Image Image
computer games


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 4:57 pm 
Veteran
User avatar

Joined: Wed Nov 18, 2009 11:17 am
Posts: 359
Location: Germany
Completed: Loren
Projects: PS2
I made a small demo independent of Loren RPGs code. The effect is still present.
You'll need the objgraph module to run it.
Though the difference is pretty noticeable in general memory consumption even without it.

Edit: Improved version.


Attachments:
File comment: New project folder
loop_test.zip [132.74 KiB]
Downloaded 9 times

_________________
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase II
Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 6:01 pm 
Ren'Py Creator
User avatar

Joined: Mon Feb 02, 2004 10:58 am
Posts: 10774
Location: Kings Park, NY
Completed: Moonlight Walks
Projects: Ren'Py
Figured it out.

Basically, there was a rule in Ren'Py that said the rollback log must always contain a label. This was there for legacy reasons - on very old versions of Ren'Py, the statement identifiers for non-label statements weren't all that stable. Keeping a label around ensured that the game would always be loadable. In modern version of Ren'Py, statement identifiers are a lot more stable, so it isn't necessary to keep a label around anymore.

In the label-jump version of your code, Ren'Py would trim the rollback log - but in the while loop version, it never saw a label, and so Ren'Py let it grow. 6.13.10 will simply prune the log back to the rollback limit, removing the legacy behavior, and making both versions of the code identical.

Thanks for putting together that demo for me - a quick demo that lets me repeat the problem is the best way for me to address a hard-to-understand problem.

_________________
Another Old-Fashioned Bishoujo Gamer
Supporting creators since 2004; Code > Drama
(When was the last time you backed up your game?)
"It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face in marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming" - Theodore Roosevelt


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 7:17 pm 
Veteran
User avatar

Joined: Wed Nov 18, 2009 11:17 am
Posts: 359
Location: Germany
Completed: Loren
Projects: PS2
No, thank you for fixing it so fast. Besides, getting the while loop back is a good feeling. :D

_________________
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase II


Top
 Profile Send private message  
 
PostPosted: Sat Mar 24, 2012 10:05 pm 
Crawling Chaos
User avatar

Joined: Mon Feb 13, 2012 5:37 am
Posts: 1113
Location: Kimashi Tower, Japan
Completed: SMAR,AAA
Projects: DMC
PyTom wrote:
I think the problem is that if you do too much allocation in Python code without returning to Ren'Py code, Ren'Py will never tick the RollbackLog forward, and you can get this problem. Although I don't know your code, chances are that you have a Python while loop as your main loop. Replace that with a Ren'Py while loop as the main loop, and things should start working.


AH, that's the case in my game. I have the memory leak problem but didn't know how to solve it. thanks too.

_________________


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group