OpenGL memory leaks when using Save User Settings. #44025

Closed
opened 2015-03-17 09:03:51 +01:00 by marc dion · 20 comments

System Information
OSX 10.9.5, i5, 16GB-Radeon 6670m

Blender Version
Hash: 4aa5109
Not sure how far back this goes.

Short description of error

User Preferences-> Save User Settings shows memory leaks when profiling with Apple's Instruments->Leaks

 

I've attached some screen-captures that show the results. They are a bit inconsistent. Sometimes 3 functions show up in the report and sometimes it's only one or two of them.

Exact steps for others to reproduce the error

This does not appear to be scene specific. There was nothing in the scene but a few lights on a hidden layer and one cube on the active layer.

I tried it several times to see if can be reproduced and at least one of the errors is showing up every time.

4_SmallLeaks.png

openGL_leak.png

openGL_MISC_A.png

openGL_leak_callTree.png

openGL_leak_drillDown.png

I also tried resetting to factory defaults, which I did twice since this has been necessary for about a year now(at least on OSX) and several several malloc and calloc errors showed up from that. The Save User Settings errors still showed up when I tried them again.

loadFactoryDefaults.png

Also, ;) drag and drop is leaking. It happens for both .blend files and image files.

(In the following image there are also 3 calloc errors but I was not paying attention to the profiler when they happened so I'm not sure what set that off. )

Usually it's only the handleDraggingEvent that shows up for that problem.

4_SmallLeaks.png

**System Information** OSX 10.9.5, i5, 16GB-Radeon 6670m **Blender Version** Hash: 4aa5109 Not sure how far back this goes. **Short description of error** User Preferences-> Save User Settings shows memory leaks when profiling with Apple's Instruments->Leaks ``` ``` I've attached some screen-captures that show the results. They are a bit inconsistent. Sometimes 3 functions show up in the report and sometimes it's only one or two of them. **Exact steps for others to reproduce the error** This does not appear to be scene specific. There was nothing in the scene but a few lights on a hidden layer and one cube on the active layer. I tried it several times to see if can be reproduced and at least one of the errors is showing up every time. ![4_SmallLeaks.png](https://archive.blender.org/developer/F152325/4_SmallLeaks.png) ![openGL_leak.png](https://archive.blender.org/developer/F152327/openGL_leak.png) ![openGL_MISC_A.png](https://archive.blender.org/developer/F152329/openGL_MISC_A.png) ![openGL_leak_callTree.png](https://archive.blender.org/developer/F152331/openGL_leak_callTree.png) ![openGL_leak_drillDown.png](https://archive.blender.org/developer/F152333/openGL_leak_drillDown.png) I also tried resetting to factory defaults, which I did twice since this has been necessary for about a year now(at least on OSX) and several several malloc and calloc errors showed up from that. The Save User Settings errors still showed up when I tried them again. ![loadFactoryDefaults.png](https://archive.blender.org/developer/F152336/loadFactoryDefaults.png) Also, ;) drag and drop is leaking. It happens for both .blend files and image files. (In the following image there are also 3 calloc errors but I was not paying attention to the profiler when they happened so I'm not sure what set that off. ) Usually it's only the handleDraggingEvent that shows up for that problem. ![4_SmallLeaks.png](https://archive.blender.org/developer/F152338/4_SmallLeaks.png)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @MarcClintDion

Added subscriber: @MarcClintDion

Added subscriber: @Sergey

Added subscriber: @Sergey

First of all, it's not really clear what are the steps to reproduce the leak. This is important to provide exact steps and sample .blend file where the issue happens 100% of cases.

Further, blender does use own guarded allocator and some of the errors reported by the tool you're using are coming from it (all those MEM_lockfree_malloc and similar functions). If the leak indeed happens, then you can run blender from the console with --debug-memory argument and on exit blender will print all non-freed datablocks. Having that list would help finding actual leaks.

Can't say anything about drag-n-drop, since don't have mach handy to test it.

P.S. Title is also seems to be misleading -- it mentions OpenGL memory, but the reports is about CPU memory by the looks of it?

First of all, it's not really clear what are the steps to reproduce the leak. This is important to provide exact steps and sample .blend file where the issue happens 100% of cases. Further, blender does use own guarded allocator and some of the errors reported by the tool you're using are coming from it (all those MEM_lockfree_malloc and similar functions). If the leak indeed happens, then you can run blender from the console with --debug-memory argument and on exit blender will print all non-freed datablocks. Having that list would help finding actual leaks. Can't say anything about drag-n-drop, since don't have mach handy to test it. P.S. Title is also seems to be misleading -- it mentions OpenGL memory, but the reports is about CPU memory by the looks of it?
Author

It's the NSOpenGLPixelFormat GHOST_ContextCGL::initializeDrawingContext() that made me think that there is something going on here with OpenGL. That one keeps coming up randomly.


  Start with the Default scene.  No .blend file is necessary.  

(i)After using ./blender --debug-memory: Open a blank scene-> 1st use Ctrl+u to save the default scene, then activate User Preferences-> Save User Settings. It only happens consistently for me when I save both the Defaults and User Settings one after the other.

For this first one, nothing is showing up in the Terminal, the leak is only showing up when I use -> Apple Dev tool: Instruments->Leaks
The screenshot shows the following functions and one of them appears to be OpenGL initialization.

SaveDefaultAndPrefs.png


(ii)After using ./blender --debug-memory: -> when opening any .blend file(With Load UI activated!, the following does not happen when Load UI is deactivated)

Error: Not freed memory blocks: 4, total unfreed memory 0.000801 MB
IDProperty len: 128 0x1121947e8
IDProperty group len: 128 0x112572a98
IDProperty string len: 128 0x112572b58
id property string 2 len: 36 0x1121948a8


(iii) After using ./blender --debug-memory: Drag and drop an image from the HD into the node Editor, Blender reports the following to the terminal.

Error: Not freed memory blocks: 4, total unfreed memory 0.000801 MB
IDProperty len: 128 0x111838c18
IDProperty group len: 128 0x111e174b8
IDProperty string len: 128 0x111e17578
id property string 2 len: 36 0x111838cd8


Next is what happens when I activate Load Factory Settings but still have the User Settings enabled so the Addons I had enabled do seem to be a factor here. When I clear out everything Blender reports no errors but with Custom Users settings(and using Default Scene/Cube) the following is reported by Blender. Here are the .blend files for startup and userpref, not sure that will be very useful since the scripts themselves are too big to load here. I'll find a way if you want them.

IDProperty len: 128 0x1119af828
IDProperty group len: 128 0x1119af8e8
IDProperty string len: 128 0x111c8ea88
id property string 2 len: 36 0x111c8eb48
IDProperty len: 128 0x114a98048
IDProperty group len: 128 0x114a98108
IDProperty string len: 128 0x114a981c8
id property string 2 len: 36 0x114a98288


With both Start up and User Preferences set to defaults, there seems to be no issues reported by Blender however,

Apple's "Instruments->Leaks" is still picking up the Save Startup/Save Prefs Combo. And the drag and drop(which looks even worse now.)

I'm too confused to take this any farther right now...

It's the NSOpenGLPixelFormat GHOST_ContextCGL::initializeDrawingContext() that made me think that there is something going on here with OpenGL. That one keeps coming up randomly. --- ``` Start with the Default scene. No .blend file is necessary. ``` --- (i)After using ./blender --debug-memory: Open a blank scene-> 1st use Ctrl+u to save the default scene, then activate User Preferences-> Save User Settings. It only happens consistently for me when I save both the Defaults and User Settings one after the other. For this first one, nothing is showing up in the Terminal, the leak is only showing up when I use -> Apple Dev tool: Instruments->Leaks The screenshot shows the following functions and one of them appears to be OpenGL initialization. ![SaveDefaultAndPrefs.png](https://archive.blender.org/developer/F152353/SaveDefaultAndPrefs.png) --- (ii)After using ./blender --debug-memory: -> when opening any .blend file(With Load UI activated!, the following does not happen when Load UI is deactivated) Error: Not freed memory blocks: 4, total unfreed memory 0.000801 MB IDProperty len: 128 0x1121947e8 IDProperty group len: 128 0x112572a98 IDProperty string len: 128 0x112572b58 id property string 2 len: 36 0x1121948a8 --- (iii) After using ./blender --debug-memory: Drag and drop an image from the HD into the node Editor, Blender reports the following to the terminal. Error: Not freed memory blocks: 4, total unfreed memory 0.000801 MB IDProperty len: 128 0x111838c18 IDProperty group len: 128 0x111e174b8 IDProperty string len: 128 0x111e17578 id property string 2 len: 36 0x111838cd8 --- Next is what happens when I activate Load Factory Settings but still have the User Settings enabled so the Addons I had enabled do seem to be a factor here. When I clear out everything Blender reports no errors but with Custom Users settings(and using Default Scene/Cube) the following is reported by Blender. Here are the .blend files for startup and userpref, not sure that will be very useful since the scripts themselves are too big to load here. I'll find a way if you want them. IDProperty len: 128 0x1119af828 IDProperty group len: 128 0x1119af8e8 IDProperty string len: 128 0x111c8ea88 id property string 2 len: 36 0x111c8eb48 IDProperty len: 128 0x114a98048 IDProperty group len: 128 0x114a98108 IDProperty string len: 128 0x114a981c8 id property string 2 len: 36 0x114a98288 --- With both Start up and User Preferences set to defaults, there seems to be no issues reported by Blender however, Apple's "Instruments->Leaks" is still picking up the Save Startup/Save Prefs Combo. And the drag and drop(which looks even worse now.) I'm too confused to take this any farther right now...

OpenGL memory and memory used by opengl initialization are totally different things.

Do you have memory leaks reported when you're using blender --debug-memory --factory-startup ?

OpenGL memory and memory used by opengl initialization are totally different things. Do you have memory leaks reported when you're using `blender --debug-memory --factory-startup` ?
Author

Added subscriber: @jensverwiebe

Added subscriber: @jensverwiebe
Author

./blender --debug-memory --factory-startup was used and I deleted Library->Application Support -> blender -> 2.74 entirely just to be sure.

Everything is coming out clean with this.


"xCode->Instruments->Leaks" is reporting:

handleDraggingEvent(,,,) is leaking 16 Bytes

and for the SaveNSave combo it's reporting

initializingDrawingContext(,,,) is leaking 96 Bytes.

WindowCocoa(,,,) is leaking 64 Bytes


"xCode->Instruments->Leaks" no longer reports an issue with loading any non-specific .blend files using 'Ctrl+o'


Now I suppose I should start enabling all the Addons a few at a time and then running each of the 3 tests again to see what is causing Blender to spill it guts.


I did try to trip up xCode's Instruments Leak tool by repeatedly pressing the "Snapshot Now" button while it was already busy and I also tried causing it grief by performing various actions using Blender while "Leaks" was accessing Blender and it did not trip from this.

I do not know this tool well enough to say much about its accuracy or reliability, although the GPU analyzer component has proven effective a finding even the smallest OpenGL buffer mis-allocations for me.


Maybe @jensverwiebe would like to fire up some of his tools since a lot of this is being triggered around OSX API doo-hickies.

./blender --debug-memory --factory-startup was used and I deleted Library->Application Support -> blender -> 2.74 entirely just to be sure. Everything is coming out clean with this. --- "xCode->Instruments->Leaks" is reporting: handleDraggingEvent(,,,) is leaking 16 Bytes and for the SaveNSave combo it's reporting initializingDrawingContext(,,,) is leaking 96 Bytes. WindowCocoa(,,,) is leaking 64 Bytes --- "xCode->Instruments->Leaks" no longer reports an issue with loading any non-specific .blend files using 'Ctrl+o' --- Now I suppose I should start enabling all the Addons a few at a time and then running each of the 3 tests again to see what is causing Blender to spill it guts. --- I did try to trip up xCode's Instruments Leak tool by repeatedly pressing the "Snapshot Now" button while it was already busy and I also tried causing it grief by performing various actions using Blender while "Leaks" was accessing Blender and it did not trip from this. I do not know this tool well enough to say much about its accuracy or reliability, although the GPU analyzer component has proven effective a finding even the smallest OpenGL buffer mis-allocations for me. --- Maybe @jensverwiebe would like to fire up some of his tools since a lot of this is being triggered around OSX API doo-hickies.
Author

Saving defaults is not required to reproduce the OpenGL errors.

While running another profiling tool(Instruments->Counters->Sample List), I was able to get glewContextInit to show up in the running list every time I opened the User Preferences dialogue.

It looks like a second thread is being called to do this, I guess that's normal for a second window...

Saving defaults is not required to reproduce the OpenGL errors. While running another profiling tool(Instruments->Counters->Sample List), I was able to get glewContextInit to show up in the running list every time I opened the User Preferences dialogue. It looks like a second thread is being called to do this, I guess that's normal for a second window...

Added subscriber: @Psy-Fi

Added subscriber: @Psy-Fi

OpenGL issues i don't see on linux, must be something platform-specific. @Psy-Fi, mind checking those on the mac in the studio?

Other issues seems are coming from your custom startup file. Without that file it is unlikely we can reproduce the issue. It might also help if you isolate what exact setting/addon is causing the issues.

OpenGL issues i don't see on linux, must be something platform-specific. @Psy-Fi, mind checking those on the mac in the studio? Other issues seems are coming from your custom startup file. Without that file it is unlikely we can reproduce the issue. It might also help if you isolate what exact setting/addon is causing the issues.
Author

I'm not able to reproduce those unsightly error dumps from Blender even when I move the 2.73 config files back into 2.74 which is pretty much what I did a week ago.

Today, now that I have restored Blender back to mostly how it was all week and using --debug-memory, mostly looks fine. I didn't reboot, not sure what changed here.


Here are some links for setting up and accessing some of Apple's profiler tools

http://www.raywenderlich.com/23037/how-to-use-instruments-in-xcode

https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/InstrumentsQuickStart/InstrumentsQuickStart.html


Apple's "OpenCL_NBody_Simulation_Example" is the closest to being like Blender when it comes to it's OpenGL setup.

https://developer.apple.com/library/mac/samplecode/OpenCL_NBody_Simulation_Example/Introduction/Intro.html

I would avoid the official openGL stuff. It all seems to be designed to force a core profile.(annoying). (4.1+ wouldn't be so bad. It includes 2.0 ES spec)

@jensverwiebe @dfelinto both use OSX I believe.

It looks like this is being called for sub-window creation but not deallocated afterwards. It seems to have undergone substantial change since 2.72

"Duplicating Area Into New Window" has the same effect as the "User Preferences" pane after being opened and closed again.

	makeAttribList(attribs, m_stereoVisual, m_numOfAASamples, needAlpha, needStencil);


	NSOpenGLPixelFormat *pixelFormat;

	pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];

	// Fall back to no multisampling if Antialiasing init failed
	if (m_numOfAASamples > 0 && pixelFormat == nil) {
		*XXX jwilkins: Does CGL only succeed when it makes an exact match on the number of samples?* Does this need to explicitly try for a lesser match before giving up?
		// (Now that I think about it, does WGL really require the code that it has for finding a lesser match?)

		attribs.clear();
		makeAttribList(attribs, m_stereoVisual, 0, needAlpha, needStencil);
		pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
	}

missingDealloc.png

I'm not able to reproduce those unsightly error dumps from Blender even when I move the 2.73 config files back into 2.74 which is pretty much what I did a week ago. Today, now that I have restored Blender back to mostly how it was all week and using --debug-memory, mostly looks fine. I didn't reboot, not sure what changed here. --- Here are some links for setting up and accessing some of Apple's profiler tools http://www.raywenderlich.com/23037/how-to-use-instruments-in-xcode https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/InstrumentsQuickStart/InstrumentsQuickStart.html --- Apple's "OpenCL_NBody_Simulation_Example" is the closest to being like Blender when it comes to it's OpenGL setup. https://developer.apple.com/library/mac/samplecode/OpenCL_NBody_Simulation_Example/Introduction/Intro.html I would avoid the official openGL stuff. It all seems to be designed to force a core profile.(annoying). (4.1+ wouldn't be so bad. It includes 2.0 ES spec) @jensverwiebe @dfelinto both use OSX I believe. It looks like this is being called for sub-window creation but not deallocated afterwards. It seems to have undergone substantial change since 2.72 "Duplicating Area Into New Window" has the same effect as the "User Preferences" pane after being opened and closed again. ``` makeAttribList(attribs, m_stereoVisual, m_numOfAASamples, needAlpha, needStencil); NSOpenGLPixelFormat *pixelFormat; pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]]; // Fall back to no multisampling if Antialiasing init failed if (m_numOfAASamples > 0 && pixelFormat == nil) { *XXX jwilkins: Does CGL only succeed when it makes an exact match on the number of samples?* Does this need to explicitly try for a lesser match before giving up? // (Now that I think about it, does WGL really require the code that it has for finding a lesser match?) attribs.clear(); makeAttribList(attribs, m_stereoVisual, 0, needAlpha, needStencil); pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]]; } ``` ![missingDealloc.png](https://archive.blender.org/developer/F152660/missingDealloc.png)
Antonis Ryakiotakis was assigned by Julian Eisel 2015-03-19 22:52:39 +01:00
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Member

Assigning to @Psy-Fi so he has the duty to check ;)

Assigning to @Psy-Fi so he has the duty to check ;)
Member

On this and already found something:
Nor yet sure what i need todo here ....
Btw: you better find it with analyse.

leak.png

Jens

On this and already found something: Nor yet sure what i need todo here .... Btw: you better find it with analyse. ![leak.png](https://archive.blender.org/developer/F153434/leak.png) Jens

This issue was referenced by 0582aa6f13

This issue was referenced by 0582aa6f130a4b1182fc5db646db3c7ac4a8ca46
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Member

Closed by commit 0582aa6f13.

Closed by commit 0582aa6f13.
Member

I commited a fix for issue documented above ( 1 left refCount ), but there is more.
Oddly if i test in xcode with "Guard Malloc", there is nothing shown and also Instruments/Leaks does not show the leak anymore.

Jens

I commited a fix for issue documented above ( 1 left refCount ), but there is more. Oddly if i test in xcode with "Guard Malloc", there is nothing shown and also Instruments/Leaks does not show the leak anymore. Jens

This issue was referenced by ff455f1ae1

This issue was referenced by ff455f1ae1ff5c309aca6b53fca361b48f3e81a1
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
5 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#44025
No description provided.