Forcing GC
-
Hello, I have an MFC program (/clr) that is a remoting client. My issue is that once we have got our remote object, then for some wacko reasons as yet unknown to me, I am unable to create a view for a frame window. The
Create
just fails. My solution to this was to create the window and hide it before the remote object was obtained and then to show/hide it as required. But the issue is that sometimes the user can do something where the remote object is created, then he goes back to the main window, then he comes back to this window where the remote frame/view is created. Now if the GC is given enough time to destroy the unused object, everything is fine. But my problem is that the GC is sorta slow on all this and I am having problems. So, how do I force the GC to destroy the remote object? And what do I do if the GC fails to recognize the object as unused and thus fails to free it? Is there anyway I can simulate adelete
on a managed object? Regards, Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Hello, I have an MFC program (/clr) that is a remoting client. My issue is that once we have got our remote object, then for some wacko reasons as yet unknown to me, I am unable to create a view for a frame window. The
Create
just fails. My solution to this was to create the window and hide it before the remote object was obtained and then to show/hide it as required. But the issue is that sometimes the user can do something where the remote object is created, then he goes back to the main window, then he comes back to this window where the remote frame/view is created. Now if the GC is given enough time to destroy the unused object, everything is fine. But my problem is that the GC is sorta slow on all this and I am having problems. So, how do I force the GC to destroy the remote object? And what do I do if the GC fails to recognize the object as unused and thus fails to free it? Is there anyway I can simulate adelete
on a managed object? Regards, Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
Nishant S wrote: The Create just fails. What is the error. What does ERR,hr say? Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
-
Nishant S wrote: The Create just fails. What is the error. What does ERR,hr say? Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
Rama Krishna wrote: What is the error. What does ERR,hr say? The view is a
CHtmlView
derived view and the call toCreate
returnsfalse
:-( I think once we've got a remote object, for some reasons we cannot create webbrowser controls. Because my Create call in theCFrameWnd
derived class didn't fail, it was only the view creation in theCFrameWnd::OnCreate
that fails :-( Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Rama Krishna wrote: What is the error. What does ERR,hr say? The view is a
CHtmlView
derived view and the call toCreate
returnsfalse
:-( I think once we've got a remote object, for some reasons we cannot create webbrowser controls. Because my Create call in theCFrameWnd
derived class didn't fail, it was only the view creation in theCFrameWnd::OnCreate
that fails :-( Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
Are you initialzing COM correctly - CoInitialize(NULL) ? [EDIT] Since you are using MFC are you calling AfxOleInit ? Nishant S wrote: Create returns false Put ERR,hr is watch window it will show you the reason why it failed. Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
-
Hello, I have an MFC program (/clr) that is a remoting client. My issue is that once we have got our remote object, then for some wacko reasons as yet unknown to me, I am unable to create a view for a frame window. The
Create
just fails. My solution to this was to create the window and hide it before the remote object was obtained and then to show/hide it as required. But the issue is that sometimes the user can do something where the remote object is created, then he goes back to the main window, then he comes back to this window where the remote frame/view is created. Now if the GC is given enough time to destroy the unused object, everything is fine. But my problem is that the GC is sorta slow on all this and I am having problems. So, how do I force the GC to destroy the remote object? And what do I do if the GC fails to recognize the object as unused and thus fails to free it? Is there anyway I can simulate adelete
on a managed object? Regards, Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
System::GC::Collect()
James "Java is free - and worth every penny." - Christian Graus -
Are you initialzing COM correctly - CoInitialize(NULL) ? [EDIT] Since you are using MFC are you calling AfxOleInit ? Nishant S wrote: Create returns false Put ERR,hr is watch window it will show you the reason why it failed. Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
Rama Krishna wrote: Are you initialzing COM correctly - CoInitialize(NULL) ? Not using any COM, not much anyway!!! [Just a few lines to get the underlying web browser control and to set the html] Rama Krishna wrote: Since you are using MFC are you calling AfxOleInit ? Hmmm. Nope. I mean I am not calling it on my own. Dunno if that might be the problem. Because the window creation (frame and view) succeeds *if* the remote object is not obtained. It fails *only* if we have obtained the remote object very puzzling, very puzzling indeed! Anyway it's part of a work-time tracking system app that I'll be submitting to CP soon, if I can only get rid of this goddamn error :-( Rama Krishna wrote: Put ERR,hr is watch window it will show you the reason why it failed. Huh? Just like that --- "Err,hr" :confused:
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
System::GC::Collect()
James "Java is free - and worth every penny." - Christian GrausJames T. Johnson wrote: System::GC::Collect() Thanks Jambo. I'll try that. But what if the GC fails to recognize the unused object as a free one. How do I tell the GC that this object is now free. Will setting it to point to NULL help in freeing the now-orphaned object??? Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Rama Krishna wrote: Are you initialzing COM correctly - CoInitialize(NULL) ? Not using any COM, not much anyway!!! [Just a few lines to get the underlying web browser control and to set the html] Rama Krishna wrote: Since you are using MFC are you calling AfxOleInit ? Hmmm. Nope. I mean I am not calling it on my own. Dunno if that might be the problem. Because the window creation (frame and view) succeeds *if* the remote object is not obtained. It fails *only* if we have obtained the remote object very puzzling, very puzzling indeed! Anyway it's part of a work-time tracking system app that I'll be submitting to CP soon, if I can only get rid of this goddamn error :-( Rama Krishna wrote: Put ERR,hr is watch window it will show you the reason why it failed. Huh? Just like that --- "Err,hr" :confused:
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
Nishant S wrote: Not using any COM, not much anyway!!! You need to initialize COM by calling AfxOleInit if you are using the webbrowser control. That is why Create fails. Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
-
James T. Johnson wrote: System::GC::Collect() Thanks Jambo. I'll try that. But what if the GC fails to recognize the unused object as a free one. How do I tell the GC that this object is now free. Will setting it to point to NULL help in freeing the now-orphaned object??? Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
Yes, you need to set it to NULL. However it would be prudent to follow Rama's thread and get to the root of the problem instead of a hack to work around what is a bug somewhere in your code. James "Java is free - and worth every penny." - Christian Graus
-
Rama Krishna wrote: Are you initialzing COM correctly - CoInitialize(NULL) ? Not using any COM, not much anyway!!! [Just a few lines to get the underlying web browser control and to set the html] Rama Krishna wrote: Since you are using MFC are you calling AfxOleInit ? Hmmm. Nope. I mean I am not calling it on my own. Dunno if that might be the problem. Because the window creation (frame and view) succeeds *if* the remote object is not obtained. It fails *only* if we have obtained the remote object very puzzling, very puzzling indeed! Anyway it's part of a work-time tracking system app that I'll be submitting to CP soon, if I can only get rid of this goddamn error :-( Rama Krishna wrote: Put ERR,hr is watch window it will show you the reason why it failed. Huh? Just like that --- "Err,hr" :confused:
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
I forgot to mention that you also need to call AfxEnableControlContainer. Nishant S wrote: Huh? Just like that --- "Err,hr" Yes. It is a very cool feature. Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
-
Yes, you need to set it to NULL. However it would be prudent to follow Rama's thread and get to the root of the problem instead of a hack to work around what is a bug somewhere in your code. James "Java is free - and worth every penny." - Christian Graus
James T. Johnson wrote: However it would be prudent to follow Rama's thread and get to the root of the problem instead of a hack to work around what is a bug somewhere in your code. I am trying to, Jambo! I really am!! The annoying thing is that everything works fine if I don't obtain the remoted object. After that everything falls down :-( Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Nishant S wrote: Not using any COM, not much anyway!!! You need to initialize COM by calling AfxOleInit if you are using the webbrowser control. That is why Create fails. Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
Rama Krishna wrote: You need to initialize COM by calling AfxOleInit if you are using the webbrowser control. That is why Create fails. Alright, then how does
Create
succeed when I don't obtain the remote object? Nish :confused:
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
I forgot to mention that you also need to call AfxEnableControlContainer. Nishant S wrote: Huh? Just like that --- "Err,hr" Yes. It is a very cool feature. Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
Rama Krishna wrote: Yes. It is a very cool feature. Damnation!!!!!!! Err,hr is S_OK Means there was no COM error. Yet the call to Create has failed!!! Have I discovered a bug????????? Sucks!!!!!!!!!! Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Rama Krishna wrote: You need to initialize COM by calling AfxOleInit if you are using the webbrowser control. That is why Create fails. Alright, then how does
Create
succeed when I don't obtain the remote object? Nish :confused:
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
I'm going to go out on a limb and say that it initializes COM for you and either MFC doesn't get to do its initialization or that it initializes it with settings incompatible with the web browser control. Just a guess :) James "Java is free - and worth every penny." - Christian Graus
-
I'm going to go out on a limb and say that it initializes COM for you and either MFC doesn't get to do its initialization or that it initializes it with settings incompatible with the web browser control. Just a guess :) James "Java is free - and worth every penny." - Christian Graus
James T. Johnson wrote: I'm going to go out on a limb and say that it initializes COM for you and either MFC doesn't get to do its initialization or that it initializes it with settings incompatible with the web browser control. What does that mean? Nish :confused:
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Rama Krishna wrote: You need to initialize COM by calling AfxOleInit if you are using the webbrowser control. That is why Create fails. Alright, then how does
Create
succeed when I don't obtain the remote object? Nish :confused:
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
Nishant S wrote: Alright, then how does Create succeed when I don't obtain the remote object? Instead of speculating over and over, it will be useful if you add those two lines of code and see whether stuff works. Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
-
Nishant S wrote: Alright, then how does Create succeed when I don't obtain the remote object? Instead of speculating over and over, it will be useful if you add those two lines of code and see whether stuff works. Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
Rama Krishna wrote: Instead of speculating over and over, it will be useful if you add those two lines of code and see whether stuff works. Yeah, I added them and it works now :-O
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]