Click here to Skip to main content
15,893,486 members
Home / Discussions / C#
   

C#

 
AnswerRe: String split [modified] Pin
musefan23-Oct-09 2:42
musefan23-Oct-09 2:42 
GeneralRe: String split Pin
Sebastian T Xavier23-Oct-09 3:23
Sebastian T Xavier23-Oct-09 3:23 
GeneralRe: String split Pin
J4amieC23-Oct-09 4:09
J4amieC23-Oct-09 4:09 
QuestionDestructor peculiarity Pin
DaveyM6923-Oct-09 1:25
professionalDaveyM6923-Oct-09 1:25 
AnswerRe: Destructor peculiarity Pin
Pete O'Hanlon23-Oct-09 1:38
mvePete O'Hanlon23-Oct-09 1:38 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 2:20
professionalDaveyM6923-Oct-09 2:20 
GeneralRe: Destructor peculiarity Pin
Pete O'Hanlon23-Oct-09 2:25
mvePete O'Hanlon23-Oct-09 2:25 
GeneralRe: Destructor peculiarity Pin
Gideon Engelberth23-Oct-09 7:47
Gideon Engelberth23-Oct-09 7:47 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 9:44
professionalDaveyM6923-Oct-09 9:44 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 9:52
professionalDaveyM6923-Oct-09 9:52 
GeneralRe: Destructor peculiarity Pin
cmk23-Oct-09 5:21
cmk23-Oct-09 5:21 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 8:10
professionalDaveyM6923-Oct-09 8:10 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 9:48
professionalDaveyM6923-Oct-09 9:48 
AnswerRe: Destructor peculiarity Pin
Gideon Engelberth23-Oct-09 7:55
Gideon Engelberth23-Oct-09 7:55 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 9:40
professionalDaveyM6923-Oct-09 9:40 
AnswerRe: Destructor peculiarity Pin
Luc Pattyn27-Oct-09 3:36
sitebuilderLuc Pattyn27-Oct-09 3:36 
GeneralRe: Destructor peculiarity Pin
DaveyM6927-Oct-09 7:04
professionalDaveyM6927-Oct-09 7:04 
GeneralRe: Destructor peculiarity Pin
Luc Pattyn27-Oct-09 7:09
sitebuilderLuc Pattyn27-Oct-09 7:09 
GeneralRe: Destructor peculiarity Pin
DaveyM6927-Oct-09 10:45
professionalDaveyM6927-Oct-09 10:45 
GeneralRe: Destructor peculiarity Pin
Luc Pattyn27-Oct-09 11:17
sitebuilderLuc Pattyn27-Oct-09 11:17 
GeneralRe: Destructor progress report 1 Pin
Luc Pattyn27-Oct-09 17:20
sitebuilderLuc Pattyn27-Oct-09 17:20 
Hi Dave,

I have simplified your code and added lots of observation code; it still behaves basically as before.

here are preliminary ideas/observations (with insufficient proof):

1. when instantiating a class with a destructor, the object is added to the finalizer queue right away;

2. when the app exits, the destructor of all objects in the finalizer queue is (probably?) executed;

3. 1+2 explains how your CloseAll gets executed at all; it does not need a GC pass, no mark-and-sweep or whatever they use to locate dead objects: at the app exit, everything is considered dead, so simply finalizing everything still in the finalizer queue makes sense (an object finalized earlier would have been removed from the list already).

4. on app exit the objects, in particular the ports, are not collected (wouldn't make any sense as all memory is about to get freed anyway).

5. the order in the finalizer queue might be simply chronological, hence your Manager instance comes before your Port instances. And as long as your Manager hasn't been collected, neither have your ports, as your Manager is keeping a list of ports.

6. I'm with Gideon[^] when he says your destructor isn't in the right place; a destructor/finalizer/dispose should not rely on any other object, so giving each Port its own destructor would solve that, and make the above #5 irrelevant.


This article[^] looks very relevant and interesting; I haven't read it completely yet.

I may write a little article on the subject. I'll be back with more.

Smile | :)

Luc Pattyn

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


GeneralRe: Destructor progress report 1 Pin
DaveyM6928-Oct-09 8:58
professionalDaveyM6928-Oct-09 8:58 
GeneralRe: Destructor progress report 1 Pin
Luc Pattyn28-Oct-09 9:54
sitebuilderLuc Pattyn28-Oct-09 9:54 
GeneralRe: Destructor progress report 1 Pin
DaveyM6928-Oct-09 10:52
professionalDaveyM6928-Oct-09 10:52 
GeneralRe: Destructor progress report 1 Pin
DaveyM6928-Oct-09 22:19
professionalDaveyM6928-Oct-09 22:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.