Page MenuHome

Fix memory leak when python safety is on.
AbandonedPublic

Authored by Jacques Lucke (JacquesLucke) on May 31 2021, 4:07 PM.

Details

Summary

To reproduce the leak:

  1. Compile with WITH_PYTHON_SAFETY.
  2. Start Blender.
  3. Switch to shader editor.
  4. Close Blender.
rna_global_pool len: 64 0x60c0001715b8   <----- This is the "main" leak.
memory pool len: 48 0x60b0001454d8
BLI_Mempool Chunk len: 2024 0x61d000f8a2b8
ghash_buckets_resize len: 88 0x60e0002dd718
rna_id len: 64 0x60c000161478
ghash_buckets_resize len: 40 0x60b00012fdc8
memory pool len: 48 0x60b00012fe78
BLI_Mempool Chunk len: 2024 0x61d000e916b8

No idea if I put this code in the right place, probably not. The leak is not really harmful currently. I just quickly looked into it because I was seeing it very often in my debug builds and wanted to know what is causing it.

Diff Detail

Repository
rB Blender
Branch
python-safety-leak (branched from master)
Build Status
Buildable 14855
Build 14855: arc lint + arc unit

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.May 31 2021, 4:07 PM
Jacques Lucke (JacquesLucke) created this revision.

Any reason not to call BKE_id_free_ex instead of having this dedicated function?

Can BKE_id_free_ex be used on embedded IDs? If yes, why is ntreeFreeEmbeddedTree necessary in the first place?

Can BKE_id_free_ex be used on embedded IDs?

It should, yes, Otherwise it must be fixed.

If yes, why is ntreeFreeEmbeddedTree necessary in the first place?

Because custom embedded node code crawling all over the place existed ages before proper generic ID management code started to be added... Fixing all of this is still on-going effort ;)

What is the reason to directly free an embedded node anyway? Those should always be freed together with their owner ID?

I don't know, I'm happy if the special case is removed. I'll try just using BKE_id_free_ex and check if it works.

  • remove ntreeFreeEmbeddedTree and use BKE_id_free instead.

Note, this does not fully work yet. Still need to figure out which
flags to pass to BKE_id_free_ex.

Jacques Lucke (JacquesLucke) planned changes to this revision.Jun 1 2021, 12:21 PM