Free Memory Question: ApplicationContext holds Form [modified]
-
Hello, I found out that my ApplicationContext instance holds a reference of my Splash window (Windows.Forms.Form), so that GC can not free the memory. (MemProfiler[^]told me) It's not a real problem for my program, but I'm curious why. My program is working like his: 1) At startup my splash form is instanciated. 2) An ApplicationContext instance is created, with my splash instance as parameter:
AppContext = new ApplicationContext(\_splash); Application.Run(AppContext);
-
Startup continious (instanciates classes like mainwindow and so on) and feeds splash with information to show. 4) Startup finished 5) Now my mainwindow is linked to the ApplicationContext and replaces the splash form.
AppContext.MainForm = _mainwindow;
_mainwindow.Show(); -
Splash is closed and local references which are linked to the splash class got disposed.
_splash.Close();
_splash = null;
.
.
It looks to me that in "5)" I'm doing something unsufficiant, so that AppContext still holds the ref to the splash. I'm open for all suggestions. Thanks for your time. All the best, MArtin -- modified at 5:38 Wednesday 13th June, 2007 The ApplicationContext holds the reference to the Splash form over the Application.ThreadContext.RunMessageLoopInner method, where the instance is passed as an argument.
-
-
Hello, I found out that my ApplicationContext instance holds a reference of my Splash window (Windows.Forms.Form), so that GC can not free the memory. (MemProfiler[^]told me) It's not a real problem for my program, but I'm curious why. My program is working like his: 1) At startup my splash form is instanciated. 2) An ApplicationContext instance is created, with my splash instance as parameter:
AppContext = new ApplicationContext(\_splash); Application.Run(AppContext);
-
Startup continious (instanciates classes like mainwindow and so on) and feeds splash with information to show. 4) Startup finished 5) Now my mainwindow is linked to the ApplicationContext and replaces the splash form.
AppContext.MainForm = _mainwindow;
_mainwindow.Show(); -
Splash is closed and local references which are linked to the splash class got disposed.
_splash.Close();
_splash = null;
.
.
It looks to me that in "5)" I'm doing something unsufficiant, so that AppContext still holds the ref to the splash. I'm open for all suggestions. Thanks for your time. All the best, MArtin -- modified at 5:38 Wednesday 13th June, 2007 The ApplicationContext holds the reference to the Splash form over the Application.ThreadContext.RunMessageLoopInner method, where the instance is passed as an argument.
Hi Martin, I have no experience wirth ApplicationContext; I once did a splash screen without it. But I just read an article[^] on it, it may interest you. Now I discovered same article here ![^] Regards,
Luc Pattyn [My Articles] [Forum Guidelines]
-
-
Hi Martin, I have no experience wirth ApplicationContext; I once did a splash screen without it. But I just read an article[^] on it, it may interest you. Now I discovered same article here ![^] Regards,
Luc Pattyn [My Articles] [Forum Guidelines]
-
Hi Martin, I have no experience wirth ApplicationContext; I once did a splash screen without it. But I just read an article[^] on it, it may interest you. Now I discovered same article here ![^] Regards,
Luc Pattyn [My Articles] [Forum Guidelines]
Hello Luc, Again, thanks for your time! I downloaded the source of the article you provided, and found out that there is exactly the same happening as in my project. Apart from that the article shows very well how a inherited ApplicationContext class can be modified for the Splash usage. So thanks for the link! I also posted the question in the article, maybe the autor is interested in that fact. All the best, Martin