mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 04:03:39 +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>
|
/// <summary>
|
||||||
/// Propagator context for .Net
|
/// Propagator context for .Net
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UserPropagator
|
public class UserPropagator : IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delegate type for fixed callback
|
/// Delegate type for fixed callback
|
||||||
|
@ -205,10 +205,20 @@ namespace Microsoft.Z3
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Release provate memory.
|
/// Release private memory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
~UserPropagator()
|
~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();
|
gch.Free();
|
||||||
if (solver == null)
|
if (solver == null)
|
||||||
ctx.Dispose();
|
ctx.Dispose();
|
||||||
|
|
Loading…
Reference in a new issue