mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 11:42:28 +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
					
				
					 1 changed files with 12 additions and 2 deletions
				
			
		|  | @ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue