mirror of
https://github.com/Z3Prover/z3
synced 2025-04-06 17:44:08 +00:00
Memory leak in .NET user-propagator (#6360)
The user-propagator object has to be manually disposed (IDisposable), otherwise it stays in memory forever, as it cannot be garbage collected automatically
This commit is contained in:
parent
58fad41dfa
commit
a67fe054d5
|
@ -37,7 +37,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Propagator context for .Net
|
||||
/// </summary>
|
||||
public class UserPropagator
|
||||
public class UserPropagator : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Delegate type for fixed callback
|
||||
|
@ -205,10 +205,20 @@ namespace Microsoft.Z3
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release provate memory.
|
||||
/// Release private memory.
|
||||
/// </summary>
|
||||
~UserPropagator()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Must be called. The object will not be garbage collected automatically even if the context is disposed
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (!gch.IsAllocated)
|
||||
return;
|
||||
gch.Free();
|
||||
if (solver == null)
|
||||
ctx.Dispose();
|
||||
|
|
Loading…
Reference in a new issue