image has numerous users when only 1 material actually is using it #42523

Closed
opened 2014-11-06 14:59:39 +01:00 by Jacob Morris · 16 comments

Window 8.1

Blender Version
Broken: 2.72b 9e963ae

I have an addon that adds siding and you can add materials to that siding with it. Some of the types of siding it adds a image texture to and if you generate the material multiple times and check how many users the image has it says a high number, when really only one material is using it. My code works by adding in an extra material and then using that material to replace the one on the object and then deleting the temporary one. So I don't know if it is just not updating that the material is deleted and not using that image anymore? Here is my code:
JARCH_siding.zip

Steps:

  1. Run "JARCH_siding.py" from the text editor
  2. Add Siding "View 3D > Add > Mesh > JARCH Vis > Add Siding
  3. Click "Cycles Materials"
  4. Add image texture
  5. Hit "Generate" several times, note how memory usage jumps
  6. Go to the node editor and note the number of users on the image.
    The part of code that adds the materials starts at line 1727
Window 8.1 **Blender Version** Broken: 2.72b 9e963ae I have an addon that adds siding and you can add materials to that siding with it. Some of the types of siding it adds a image texture to and if you generate the material multiple times and check how many users the image has it says a high number, when really only one material is using it. My code works by adding in an extra material and then using that material to replace the one on the object and then deleting the temporary one. So I don't know if it is just not updating that the material is deleted and not using that image anymore? Here is my code: [JARCH_siding.zip](https://archive.blender.org/developer/F122256/JARCH_siding.zip) Steps: 1. Run "JARCH_siding.py" from the text editor 2. Add Siding "View 3D > Add > Mesh > JARCH Vis > Add Siding 3. Click "Cycles Materials" 4. Add image texture 5. Hit "Generate" several times, note how memory usage jumps 6. Go to the node editor and note the number of users on the image. The part of code that adds the materials starts at line 1727
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @BlendingJake

Added subscriber: @BlendingJake

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Antonis Ryakiotakis self-assigned this 2014-11-06 15:38:13 +01:00

Materials never get deleted from the database when you create them unless you close blender - if you search for them in the material search field you will find them. To make sure your image does not have any users you have to basically remove all references of the image from the temporary material. But again creating so many materials looks like a bad idea, you might want to consider caching them.

This looks like working as intended and patch is more than 2000 lines and -sorry to say- written like a wall of text so it's quite hard to figure out what is happening. It would be good to have a few steps with a blend file where image leaking can be demonstrated.

Materials never get deleted from the database when you create them unless you close blender - if you search for them in the material search field you will find them. To make sure your image does not have any users you have to basically remove all references of the image from the temporary material. But again creating so many materials looks like a bad idea, you might want to consider caching them. This looks like working as intended and patch is more than 2000 lines and -sorry to say- written like a wall of text so it's quite hard to figure out what is happening. It would be good to have a few steps with a blend file where image leaking can be demonstrated.

Closing until a real leak can be shown.

Closing until a real leak can be shown.
Author

@Psy-Fi
The thing is though that the material is being deleted. If you check bpy.data.materials the material is not there. Did you just run the code and see the issue? I understand that it is hard to read threw other peoples code and it is hard to simplify this down, as when you restart Blender the issue is gone, but to my understanding it shouldn't be holding onto it since the material is no longer listed.

@Psy-Fi The thing is though that the material is being deleted. If you check bpy.data.materials the material is not there. Did you just run the code and see the issue? I understand that it is hard to read threw other peoples code and it is hard to simplify this down, as when you restart Blender the issue is gone, but to my understanding it shouldn't be holding onto it since the material is no longer listed.

Changed status from 'Archived' to: 'Open'

Changed status from 'Archived' to: 'Open'

Reopening, confirmed. Materials seem to be deleted also

Reopening, confirmed. Materials seem to be deleted also
Author

Added subscriber: @Psy-Fi

Added subscriber: @Psy-Fi
Author

Thanks @Psy-Fi, I do hope to update my code, but this did seem to be a bug.

Thanks @Psy-Fi, I do hope to update my code, but this did seem to be a bug.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

@ideasman42 I see this is caused by 916a58f4e

I don't have valgrind here to check for details but enabling with address sanitizer seems fine. Also if this is problematic on quit might be worth NULLing out the pointers first on exit or so?

@ideasman42 I see this is caused by 916a58f4e I don't have valgrind here to check for details but enabling with address sanitizer seems fine. Also if this is problematic on quit might be worth NULLing out the pointers first on exit or so?

Added subscriber: @Sergey

Added subscriber: @Sergey

Well, user counters are only guaranteed to be correct after loading the file. Deleting datablocks might cause dangling users for until next save/reload. Making it so user counter is always correct is rather a huge topic and wouldn't really consider this is a bug.

Unless there are more issues here @Psy-Fi?

Well, user counters are only guaranteed to be correct after loading the file. Deleting datablocks might cause dangling users for until next save/reload. Making it so user counter is always correct is rather a huge topic and wouldn't really consider this is a bug. Unless there are more issues here @Psy-Fi?

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

No, that should be it.

No, that should be it.
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
3 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#42523
No description provided.