Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/SIL.LCModel.Utils/ArrayPtr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public bool IsDisposed
/// ------------------------------------------------------------------------------------
~ArrayPtr()
{
//if (this != s_null) // TODO (Hasso) 2016.11: is this the only place this ugly hack is needed?
Dispose(false);
// The base class finalizer is called automatically.
}
Expand Down Expand Up @@ -150,8 +149,8 @@ public void Dispose()
/// ------------------------------------------------------------------------------------
protected virtual void Dispose(bool disposing)
{
// If you're getting this line it means that you forgot to call Dispose().
Debug.WriteLineIf(!disposing,// && this != s_Null, // TODO (Hasso) 2016.11: is this the only place this ugly hack is needed?
// Only warn for finalized instances that actually own allocated memory.
Debug.WriteLineIf(!disposing && m_ownMemory,
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new warning condition uses m_ownMemory, but m_ownMemory == true does not necessarily mean unmanaged memory was actually allocated (e.g., new ArrayPtr() sets m_ownMemory = true while m_ptr is still IntPtr.Zero until Resize is called). As written, finalized instances created via the default ctor but never allocated could still emit the warning, which contradicts the new comment and can still produce false positives. Consider including an allocation check (e.g., m_ptr != IntPtr.Zero / m_Size >= 0) or adjust the comment to match the actual condition.

Suggested change
Debug.WriteLineIf(!disposing && m_ownMemory,
Debug.WriteLineIf(!disposing && m_ownMemory && m_ptr != IntPtr.Zero,

Copilot uses AI. Check for mistakes.
"****** Missing Dispose() call for " + GetType().Name + ". ****** ");

// Must not be run more than once.
Expand Down
Loading