BVHTree object is not dealloced when using global operator in code. #47556

Closed
opened 2016-02-24 18:29:43 +01:00 by Germano Cavalcante · 8 comments

System Information
Windows 64bits

Blender Version
Broken: 2.76

Short description of error
When you have finished running a python code with a BVHTree object, it is expected that it's tree has been released at the end of the code and not when close Blender. Unfortunately the object is not dealloced when the code has the "global" operator anywhere
.
Exact steps for others to reproduce the error
run this code:

import bpy
from mathutils import bvhtree
print("-------------------------------")

gl = None
def get_global_gl():
    global gl
    return gl

obj = bpy.context.object
scene = bpy.context.scene

tridata = bvhtree.BVHTree.FromObject(obj, scene)
#del tridata

And make sure that the BVHTree object has been dealloced (I put a printf in the source code).

**System Information** Windows 64bits **Blender Version** Broken: 2.76 **Short description of error** When you have finished running a python code with a BVHTree object, it is expected that it's tree has been released at the end of the code and not when close Blender. Unfortunately the object is not dealloced when the code has the "global" operator anywhere . **Exact steps for others to reproduce the error** run this code: ``` import bpy from mathutils import bvhtree print("-------------------------------") gl = None def get_global_gl(): global gl return gl obj = bpy.context.object scene = bpy.context.scene tridata = bvhtree.BVHTree.FromObject(obj, scene) #del tridata ``` And make sure that the BVHTree object has been dealloced (I put a printf in the source code).
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @mano-wii

Added subscriber: @mano-wii
Author
Member

EDIT: Does not even need the "global" statement, only a function is enough.

EDIT: Does not even need the "global" statement, only a function is enough.

Added subscriber: @NikoLeopold

Added subscriber: @NikoLeopold

Added subscribers: @ideasman42, @Sergey

Added subscribers: @ideasman42, @Sergey
Campbell Barton was assigned by Sergey Sharybin 2016-02-25 10:39:05 +01:00

@ideasman42, not sure it's supposed to be freed that way actually, mind having a look?

@ideasman42, not sure it's supposed to be freed that way actually, mind having a look?

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

This is Python's GC - known behavior.

If we want we could do a gc.collect() before exiting which resolves most cases, but not sure its really worth it since this is known CPython behavior and only going to make exit slower for something which is harmless and only a bit confusing when debugging. see: http://stackoverflow.com/questions/14628486

We could run gc.collect() with debug builds, or check the --debug-python flag.

This is Python's GC - known behavior. If we want we could do a `gc.collect()` before exiting which resolves most cases, but not sure its really worth it since this is known CPython behavior and only going to make exit slower for something which is harmless and only a bit confusing when debugging. see: http://stackoverflow.com/questions/14628486 We could run gc.collect() with debug builds, or check the `--debug-python` flag.
Sign in to join this conversation.
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
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#47556
No description provided.