deleting objects caused "Finalization error" when threading

Vladimir Panteleev thecybershadow at gmail.com
Sun Jun 29 02:41:54 PDT 2008


On Sun, 29 Jun 2008 12:18:37 +0300, Frank Benoit  
<keinfarbton at googlemail.com> wrote:

> Huang Guan schrieb:
>> Hi, I am still writing my Web Server program and I still can not go  
>> through the problems that might be caused by GC. I often catch the  
>> exception "Finalization error" when a connection is being deleted.  As  
>> I have been accustomed to deleting objects when I don't use it( Want to  
>> release memory quickly ), I wrote many "delete" statements. I think the  
>> problem above happens when a thread is deleting a object, but which is  
>> at the moment used by another thread, then it causes the "Finalization  
>> error" exception.  I don't know whether I am right or not.
>> But as I replaced the "delete obj" instead of "obj = null", the problem  
>> seldom happened.
>>  Do you have any ideas?
>>
>
> The 'Finalization error' is thrown, if a destructor has thrown an  
> exception, which is not allowed.

Thus, it's likely that you missed one or more delete statements in your  
code, then the garbage collector picked up an object and its children  
(objects to which only the parent object has references to). Since the  
order the GC destroys unreferenced objects is undetermined, you're  
probably trying to manually delete a child in your parent destructor's  
class, when that child has already been deleted by the GC.

-- 
Best regards,
  Vladimir                          mailto:thecybershadow at gmail.com



More information about the Digitalmars-d mailing list