Regular Out Of Memory Errors

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
User avatar
rjayne
Newbie
Posts: 15
Joined: Wed Feb 25, 2015 7:48 am
Contact:

Regular Out Of Memory Errors

#1 Post by rjayne »

Hi, I've been trying to troubleshoot and solve this issue I'm having for a little while now and nothing seems to really work. Some of the other posts where people experience Out Of Memory issues seem to be a lot more understandable (400 high resolution image loops being initialized and firing for example) but I seem to be using Ren'Py in much the same way I always have and it's leading to constant errors in playback. The program itself also seems to eat up memory on my PC in general, even when I'm not running a game, or in the very least prevents me from using other programs in their intended way. I'm going to provide as much detail as I can so I don't miss something that might be important, feel free to skip down to the error code down below.

Before I begin, here are my pc stats:
Intel Core i7 870 @ 2.93GHz
14 GB Ram
Windows 10 x64
GeForce GTX 1050 Ti 4GB (Display)
GeForce GT 730 2GB (secondary, for cuda render stacking)


It is a fairly old machine, but it handles most other things, and other game engines like Unity, with relative ease, so I assumed it isn't the machine, but I could be wrong.

Anyway onto the game. It's currently quite short (2k words / 2300 lines) consisting of 137, 1280x853 sized PNG files that have been compressed down for size. These files are pre-rendered images, so in game, all I'm doing is loading an old image out, and placing a new image in - no need for layering sprites over them, it's a slideshow of sorts. I initially was using show and hide, but switched to using scenes and turning all of the images into children of a single scene (sc 1 - sc 100, for example) as I read this minimizes memory usage since you're unloading the old ones and loading in the new ones as needed. Here is an example of a short section:

Code: Select all

    scene s 45
    with dissolve 
    
    tay "Do you hang with Tash much?"
    
    scene s 55
    with dissolve

    desi "Oh, actually not really. More like, friend of a friend type of deal?"
    
    scene s 60
    with dissolve 
    
    tay "She does seem to hang with a different crowd now..."
    
    scene s 55
    with dissolve 
    
    desi "She wasn't always a party animal?"
    
    scene s 46
    with dissolve 
    tay "Our version of partying was smoking up and watching anime..."
    
    scene s 63
    with dissolve 
I also have two image maps (I'm using image button code now since it's been said to be more efficient), they both have 3-4 options being drawn over a single ground map. These sections are where most of the out of memory errors occur, but it isn't repeatable, happening at different times every play through, and sometimes not at all. These maps are using 1280x853 sized transparent 'button' images, uncropped, so I don't have to fudge around with placement. I know that I can increase performance by trimming the transparency out and placing them manually, and I might do that next, but I would like an imagemap with 20 buttons, and I'm getting lag at 4 - so something else seems to be fundamentally wrong. Here is my code:

Code: Select all

 screen handbagOptions1():
        add "buttons/map2_ground.png"
        
        imagebutton auto "buttons/m2_wine_%s.png" action Jump('wine') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_perfume_%s.png" action Jump('perfume') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_brush_%s.png" action Jump('brush') xpos 0 ypos 0 focus_mask True
        
        imagebutton auto "buttons/m2_cigg_%s.png" action Jump('cigg') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_cream_%s.png" action Jump('cream') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_eyeliner_%s.png" action Jump('eyeliner') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_lighter_%s.png" action Jump('lighter') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_lippy_%s.png" action Jump('lippy') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_tamp_%s.png" action Jump('tamp') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_marker_%s.png" action Jump('marker') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_monz_%s.png" action Jump('monz') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_teddy_%s.png" action Jump('teddy') xpos 0 ypos 0 focus_mask True
        
        imagebutton auto "buttons/m2_spliff_%s.png" action Jump('spliff') xpos 0 ypos 0 focus_mask True
        
        imagebutton auto "buttons/m2_sucker_%s.png" action Jump('sucker') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_pen_%s.png" action Jump('pen') xpos 0 ypos 0 focus_mask True
        
        #imagebutton auto "buttons/m2_water_%s.png" action Jump('water') xpos 0 ypos 0 focus_mask True
    
        if seenEyeTut == False:
            add "buttons/eye_tut.png" xalign 0.0 yalign 0.0
        elif seenEyeTut == True:
            add "buttons/eye.png" xalign 0.0 yalign 0.0
            
    call screen handbagOptions1()
As you can see I've taken out most of the options and pulled it down to four to increase performance and reduce lag, but even four which is my bare minimum for story reasons, creates issues. I would like this game to be playable on android and iOS in the long run, so these kinds of issues happening on PC makes me wonder if I have any chance, since I don't seem to be pushing the program very hard before it collapses in on itself even on PC.

Some of the troubleshooting I've done based on other posts I've found here:
  • I was initially scaling all of the images when they were defined to 1920x1080, so removed the scaling code and changed the project size, which led to some improvement.
  • I've tried making use of $ renpy.free_memory() at regular intervals, and this has led to further minor improvement, but there are still issues.
  • I've increased the projects image cache to 64, with no noticeable difference.
  • I've locked the framerate at 30, again with no real difference.
  • I've rollbacked renpy to 6.99.13 (which seemed to help a lot, the most recent update was crashing occasionally even while idling, which I'm no longer getting).
I've kept an eye on the texture/memory log while playing, and it will stabilize at 30 - 80mb before the imagemaps, and around 100-150mb while the imagemaps are in memory, the image cache (default size) never bounces up past 20%. Before I used the free renpy code, it would hit around 300mb by this point in the game and bounce up to around 35% used. To me that would seem to imply everything should be running smoothly?

I am also using a custom cursor, for reference.

Here are my questions:
  • Am I doing anything obviously wrong in how I'm approaching the game, I've only made a few renpy games in the past and I'm still constantly learning, so please point anything out. I am still a noob with Python.
  • What are some things I can try out to optimize the project that I haven't tried, so that it can run the best it can, considering I'd like to have it run on iOS and android. It seems like such a small game in comparison to other games I've seen on Ren'Py and I have no idea what I'm doing wrong.
  • And most importantly, how can I fix the regular but seemingly random out of memory errors?
here is one of the errors being spat out by 6.99.13:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 2018, in script
    $ renpy.pause(.5, hard='True')
  File "game/script.rpy", line 2018, in <module>
    $ renpy.pause(.5, hard='True')
MemoryError: 

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\bootstrap.py", line 305, in bootstrap
    renpy.main.main()
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\main.py", line 499, in main
    run(restart)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\main.py", line 147, in run
    renpy.execution.run_context(True)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\execution.py", line 795, in run_context
    context.run()
  File "game/script.rpy", line 2018, in script
    $ renpy.pause(.5, hard='True')
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\ast.py", line 827, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\python.py", line 1764, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 2018, in <module>
    $ renpy.pause(.5, hard='True')
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\exports.py", line 1304, in pause
    rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\ui.py", line 287, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\display\core.py", line 2553, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\display\core.py", line 2916, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\display\core.py", line 1980, in draw_screen
    renpy.config.screen_height,
  File "renpy/display/render.pyx", line 430, in renpy.display.render.render_screen (gen\renpy.display.render.c:6938)
    rv = render(root, width, height, 0, 0)
  File "renpy/display/render.pyx", line 196, in renpy.display.render.render (gen\renpy.display.render.c:2983)
    rv = d.render(widtho, heighto, st, at)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\display\layout.py", line 702, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 110, in renpy.display.render.render (gen\renpy.display.render.c:3445)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 196, in renpy.display.render.render (gen\renpy.display.render.c:2983)
    rv = d.render(widtho, heighto, st, at)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\display\im.py", line 503, in render
    texture = cache.get(self, texture=True)
  File "F:\DAZ 3D\Daz Renpy\renpy-6.99.13-sdk\renpy\display\im.py", line 248, in get
    ce.texture = renpy.display.draw.load_texture(ce.surf)
  File "renpy/gl/gldraw.pyx", line 684, in renpy.gl.gldraw.GLDraw.load_texture (gen\renpy.gl.gldraw.c:9897)
    rv = gltexture.texture_grid_from_surface(surf, transient)
  File "renpy/gl/gltexture.pyx", line 889, in renpy.gl.gltexture.texture_grid_from_surface (gen\renpy.gl.gltexture.c:11852)
    tex.load_surface(surf, x, y, width, height,
  File "renpy/gl/gltexture.pyx", line 330, in renpy.gl.gltexture.TextureCore.load_surface (gen\renpy.gl.gltexture.c:4175)
    self.premult = premultiply(
  File "renpy/gl/gltexture.pyx", line 1180, in renpy.gl.gltexture.premultiply (gen\renpy.gl.gltexture.c:16689)
    rv = PyString_FromStringAndSize(<char *>NULL, w * h * 4)
MemoryError: 

Windows-8-6.2.9200
Ren'Py 6.99.13.2919
here is another by 6.99.14.3:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
error: Out of memory

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "F:\DAZ 3D\Daz Renpy\Renpy v6.99.14.3\renpy\bootstrap.py", line 306, in bootstrap
    renpy.main.main()
  File "F:\DAZ 3D\Daz Renpy\Renpy v6.99.14.3\renpy\main.py", line 524, in main
    renpy.display.interface.finish_pending()
  File "F:\DAZ 3D\Daz Renpy\Renpy v6.99.14.3\renpy\display\core.py", line 3524, in finish_pending
    self.check_background_screenshot()
  File "F:\DAZ 3D\Daz Renpy\Renpy v6.99.14.3\renpy\display\core.py", line 2106, in check_background_screenshot
    self.bgscreenshot_surface = renpy.display.draw.screenshot(self.surftree, self.fullscreen_video)
  File "gldraw.pyx", line 1349, in renpy.gl.gldraw.GLDraw.screenshot
  File "F:\DAZ 3D\Daz Renpy\Renpy v6.99.14.3\renpy\display\pgrender.py", line 116, in surface
    surf = Surface((width + 4, height + 4), 0, sample)
  File "src/pygame_sdl2/surface.pyx", line 164, in pygame_sdl2.surface.Surface.__init__ (gen\pygame_sdl2.surface.c:2738)
error: Out of memory

Windows-8-6.2.9200
Ren'Py 6.99.14.3.3347
I'm kind of useless when it comes to trying to decipher the error logs so I hope they are relevant/useful to the issue at hand. Thank you so much, and sorry for writing up such a long post. Happy to provide any other details needed.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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: Regular Out Of Memory Errors

#2 Post by PyTom »

Can you post the log.txt, please?

I've been contacted by a few people on this, and it appears to be related to the Nvidia drivers, and perhaps due to SLI. I wasn't able to solve this at a Ren'Py level, as I suspect the cause is a leak in Nvidia's stuff. Perhaps more information would let us file a bug report with them.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
rjayne
Newbie
Posts: 15
Joined: Wed Feb 25, 2015 7:48 am
Contact:

Re: Regular Out Of Memory Errors

#3 Post by rjayne »

Sure, I'd be happy to. It would be a relief to hear that it wasn't something on my end or Renpy's, but some driver mess up, that being said hopefully it can get fixed quickly if that's the case. Maybe I can rollback my drivers to fix it in the mean time?

In terms of logs I wasn't sure which you needed, they all seem similar in what they say but I uploaded the logs from the game and the main programs just to be sure.

Edit: just to clarify after rereading your comment, I'm not running the cards in SLI mode since they're different models. But they are both connected.
Attachments
log_game.txt
(13.63 KiB) Downloaded 98 times
log_966143.txt
(13.67 KiB) Downloaded 90 times
log_69913.txt
(13.58 KiB) Downloaded 163 times

User avatar
rjayne
Newbie
Posts: 15
Joined: Wed Feb 25, 2015 7:48 am
Contact:

Re: Regular Out Of Memory Errors

#4 Post by rjayne »

Sorry to bump the thread, but I keep running into the same issues and it's really cutting into the development of this project. Are there any ideas as to quick fixes I could use to bypass this potential nVidea memory leak? Would you suggest running an old set of drivers, or something along that route? Does the prerelease of 7.0 have the same compatibility issues? I'll take any suggestions at this point.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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: Regular Out Of Memory Errors

#5 Post by PyTom »

Sorry, I don't have an answer for this. I've seen multiple people with this, and the common thread is that it's happened in systems with multiple Nvidia cards. I haven't been able to find a cause in Ren'Py, probably because the issue is likely somewhere in Nvidia's GL library or driver software. The one thing I'd do would be to potentially try pulling one of your GPUs to see if that fixes the problem, but that's a lot ot ask.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
rjayne
Newbie
Posts: 15
Joined: Wed Feb 25, 2015 7:48 am
Contact:

Re: Regular Out Of Memory Errors

#6 Post by rjayne »

It is a little difficult because I go back and forward with rendering images out using both video cards, back to renpy to utilize those renders. I would be very curious to see if it did fix the issue though, so I might experiment with it later today and see if it actually does make a difference, would the results of that help you think? Also, would I need to reinstall all of my nVid drivers after pulling the card out to make sure the installed drivers for the then uninstalled card would continue to conflict?

Thanks again.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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: Regular Out Of Memory Errors

#7 Post by PyTom »

Sorry, was busy for the last week.

Um... I don't know, honestly. I've had this problem reported twice, and both people had multiple Nvidia video cards. If we have a problem that is there with two cards, and not with one, then I think that's the sort of problem we can report to Nvidia so they can fix their drivers. If not, then that might be good also - I could use patreon money to get a card and pop it into my new windows box, and see if that has the same problem.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: akakyouryuu, GetOutOfMyLab, Google [Bot]