mirror of
				https://github.com/Z3Prover/z3
				synced 2025-11-04 13:29:11 +00:00 
			
		
		
		
	Try freeing context in dispose method and not wait for finalizer #5043
This commit is contained in:
		
							parent
							
								
									c6eb55537a
								
							
						
					
					
						commit
						f7b1469462
					
				
					 1 changed files with 9 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -4808,16 +4808,6 @@ namespace Microsoft.Z3
 | 
			
		|||
        {
 | 
			
		||||
            // Console.WriteLine("Context Finalizer from " + System.Threading.Thread.CurrentThread.ManagedThreadId);
 | 
			
		||||
            Dispose();
 | 
			
		||||
 | 
			
		||||
            if (refCount == 0 && m_ctx != IntPtr.Zero)
 | 
			
		||||
            {
 | 
			
		||||
                m_n_err_handler = null;
 | 
			
		||||
                IntPtr ctx = m_ctx;
 | 
			
		||||
                m_ctx = IntPtr.Zero;
 | 
			
		||||
                Native.Z3_del_context(ctx);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                GC.ReRegisterForFinalize(this);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -4847,6 +4837,15 @@ namespace Microsoft.Z3
 | 
			
		|||
            m_intSort = null;
 | 
			
		||||
            m_realSort = null;
 | 
			
		||||
            m_stringSort = null;
 | 
			
		||||
            if (refCount == 0 && m_ctx != IntPtr.Zero)
 | 
			
		||||
            {
 | 
			
		||||
                m_n_err_handler = null;
 | 
			
		||||
                IntPtr ctx = m_ctx;
 | 
			
		||||
                m_ctx = IntPtr.Zero;
 | 
			
		||||
                Native.Z3_del_context(ctx);
 | 
			
		||||
            }
 | 
			
		||||
            else 
 | 
			
		||||
                GC.ReRegisterForFinalize(this);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue