BGE leaves references in memory after quitting #44557
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#44557
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description:
When the BGE quits, there are still remainders of game engine objects in memory. This can be seen when inspecting
gc.get_objects()
. These are probably dead proxies, which apparently can still hold references.Tested on: Blender 2.74 and latest version from Git (
f8540d7fd5
)Running Kubuntu Linux 14.10 64-bit, compiled the version from Git with GCC 4.9.1-16ubuntu6
To reproduce:
Run the script again, and check the terminal for output. On my machine it shows:
I see two things amiss:
sys.modules
though, I checked that.Changed status to: 'Open'
Added subscribers: @dr.sybren, @brita
PS: for fun, press F8 to reload scripts, then run the script again. Boom, Blender crashes (if not, try again).
Added subscriber: @AngusHollands-4
We get into a heap of trouble (excuse the pun) because of persistent Python interpreter state, not only for internal objects, but also imported modules (any modules with mutable state that were imported before the engine was run will not be cleared after exit). This can be worked around, but it's a reflection of the issues observed.
Added subscriber: @Blendify
Added subscriber: @panzergame
it seems that the GameLogic module is never freed, if you defined the destructor function you will see that is never called.
This issue was referenced by
cd24871706
Changed status from 'Open' to: 'Resolved'
This issue was referenced by
77ce7eb541
Changed status from 'Resolved' to: 'Open'
Commit
cd24871706
re-introduced problems with starting the game engine multiple times in the same run of Blender. I have reverted in commit77ce7eb541
.I've attached a project that shows this issue: #44557-memleak-reloading.tar.bz2. Run the BGE once, and it'll stop immediately (correctly, due to the
bge.logic.endGame()
call int44557.bge.submodule2.startup
). Run the BGE again, and you'll see a nice error message.It probably has something to do with the
t44557.bge
module already getting loaded from Blender, before the BGE starts. However, I feel that we should still support this (and apart from the memory leak, it works fine in current Blender).Added subscriber: @you.le
Hi, I can't reproduce this bug with recent Blender's version... Or I'm missing something? http://www.pasteall.org/pic/95569
@dr.sybren, as i understand the GameLogic module is never freed and reused the next frame because it contains only "globalDict" which is set as game end if we just reload an other file.
An other simple test is to do:
And then you will see that "a" is incremented for each run. But i debug the code in some hours and didn't find why it reuse the same module dictionnary because the module pointer and dictionnary is always a new modules, also the system modules dict is the same.
And even if we free the module by doing :
The issue is still here.
Trying to import "bge" or "bge.logic" or "GameLogic" outside bge raise an eror as exepted.
Also a big point that i forget : i renamed the folder bge to bge2
Apparently clear the sys.modules dictionnary before run the BGE and after run your script make it works. But it means that the BGE can't work on a python "context" modified by blender. So i propose to do like BGE : at blender start make a copy of the sys.modules and when laucnh the BGE load this copied dictionnary.
little fix patch : http://www.pasteall.org/67417/diff
Removed subscriber: @Blendify
We need to be sure that after exiting the game, the original sys.modules entries are returned (your patch would leave the python modules dictionary in the same state as a clean blender instance (not preserving running addons etc)
@AngusHollands-4: in the patch we first copy the actual sys.modules then set the clean one and at the game end we restore the copy of the actual sys.modules. So everything is ok.
Changed status from 'Open' to: 'Archived'
This task is being closed because the BGE has been removed in Blender 2.8.