Skip to content

Commit

Permalink
re-removing prune_ugens(); add more description
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 22, 2024
1 parent 328742f commit 23b773c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/chuck_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1985,11 +1985,21 @@ void Chuck_VM_Shred::detach_ugens()
iter++;
}

// prune ugens still associated with the shred
// prune UGens still associated with the shred by refcount...
// ---
// as of 1.5.4.2 this is no longer necessary in the general and non-OTF
// case; but for OTF replace and remove, this will conservatively release
// ugens (e.g., with refcount==1); see prune_ugens() for more info
prune_ugens();
// ---
// BUT WAIT... we can't reliably do this, because a UGen can be created
// on a shred, copy its reference to a variable that originates from a
// different shred and let the original reference go out of scope; this
// could result in the UGen refcount==1 but should NOT be released yet.
// COMMENTING OUT (again) NOTE: this affects OTF operations such as
// remove and replace and (in theory) nothing beyond those, as there
// are mechanisms for properly cleaning up UGens otherwise
// ---
// prune_ugens();

// clear map
m_ugen_map.clear();
Expand All @@ -2015,7 +2025,7 @@ void Chuck_VM_Shred::detach_ugens()
// if references are within a shred's context or outside of it
//-----------------------------------------------------------------------------
// TODO: the right way to handle this would be to carefully unwind the
// execution context: function call stacks and stmt-level releases
// shred's execution context: function call stacks and stmt-level releases
// possibly letting the current stmt finish if there is memory to be released
// AND then unwinding the call stack and releasing things along the way
//-----------------------------------------------------------------------------
Expand Down

0 comments on commit 23b773c

Please sign in to comment.