Page 1 of 2
Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Tue Dec 18, 2012 2:24 pm
by mwerksma
Hello,
I have created an ActiveX with C# and VS2010 and it works fine.
Start the panel, play with ActiveX, close panel, ActiveX is out of memory.
But when I open this panel from another panel, close the panel with the ActiveX on it,
the ActiveX stays in memory because the parent form stays open.
So a memory leak is born
Can anybody tell me how to destroy/cleanup the ActiveX when the Terminate of the
form is activated so the ActiveX will we out of the memory of the computer?
This is a big problem for me because the ActiveX will be used at our customer.
Thank you in advance,
Marcel Werksma
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Tue Dec 18, 2012 5:08 pm
by tmalone
If you block the user from using the X button on the title bar, you can force him to use a close button on your popup. This will allow you to execute cleanup script before initiating the panelOff(). I have used this technique many times to transfer choices from a panel to DPEs in one call vs. each time the user makes a selection.
Good Luck,
Todd Malone
HMI CoC
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Wed Dec 19, 2012 8:44 am
by mwerksma
Hi Todd,
Thank you but how does the cleanup code looks like with an ActiveX?
I have full control when the panel is closed by the user, no X button
is available on the panel.
Marcel Werksma
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Wed Dec 19, 2012 10:07 am
by leoknipp
Hello,
in the WinCC OA-UI a caching functionality is implemented to improve the time to load the panels when they are opened again after starting the UI.
In the described case the ActiveX-element is still present in the cache when closing the panel.
At the panel properties you can define if panel-caching shall be used.
Please set the parameter "Keep in Parameter" to "FALSE", save the panel and try if it works.
Best Regards
Leopold Knipp
Senior Support Specialist
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Wed Dec 19, 2012 10:49 am
by mwerksma
Hello Leopold,
Thank you for your suggestion but I have already change the parameter Keep in Memory to FALSE but the problem still occurs.
Any other ideas?
Marcel Werksma
Siemens Nederland N.V.
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Wed Dec 19, 2012 4:29 pm
by fmulder
Mr Werksma,
Try running your GUI from your Visual Studio 2010 debugger and see if you enter the ActiveX's destructor when you close the PSVS panel. I've done this before and had the same issue with the caching of the panel. Please do so to ensure that the memory leak is not somewhere else in your ActiveX
Also, you could try to disable the caching for the entire project in the config file.
[ui]
panelCacheSize = 0
If you plan to implement more graphical elements then you should seriourly consider switching to Qt. Developing a widget in Qt has many advantages (can be transparant, no registration, multi-platform, no dependencies on .NET, most powerfull graphical framework).
If you want to program beautiful stuff -> consider Qt !
Good luck
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Thu Dec 20, 2012 9:16 am
by mwerksma
Mr. Mulder,
The destructor is not entered when I close the PVSS panel.
I added an extra boolean property to my C# ActiveX which I force to TRUE in the Terminate event script of the PVSS panel.
In the C# code I've added extra code which is started on setting the property and has code to dispose the AxctiveX.
But I think it is not possible to dispose the AxtiveX from within itself.
You wrote you did the same but how did you solve the problem?
You code was probably written in C++ code but the solution should be the same, isn't it?
I have added the entry you mentioned in my config and restarted PVSS but sadly did not solve the problem.
Thank you for your time,
Marcel Werksma
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Thu Dec 20, 2012 10:13 am
by fmulder
Dear Mr Werksma,
The GIS Viewer EWO that you'll see in PVSS was initially developed as an C++ ActiveX. When you opened the PVSS panels, maps were being loaded and the ActiveX would draw a combination of layers. Problem was that I had a huge memory leak. I added some breakpoints and found that I never entered my destructor. I had a huge memory leak and eventually found that my ActiveX was adding more and more maps (and layers) because it had never removed the previous one.
I then change the settings for the panel cache. This fixed the whole issue.
I would asdvise you to write a very small C++ ActiveX using Visual Studio 2010. Should not take more than 10 minutes and test this. I'm not sure why you're C# component would work differently. Also, my ActiveX work was back in version 3.8 (and not 3.10)
Good luck
Frenk
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Thu Dec 20, 2012 1:39 pm
by mwerksma
Mr. Mulder,
I have tried everything, including starting the garbage collector.
Also I read a lot about the destructor feature in Dot.Net but sadly I can not solve the problem.
I only program the ActiveX code in C# and VB.Net because I am used doing so.
A C++ ActiveX is a problem for me. All te on-line examples I see don't applie to ActiveX code.
I will keep om trying and I hope the problem will be solved soon.
Regards Marcel
Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script
Posted: Thu Dec 20, 2012 1:48 pm
by fmulder
Mr Werksma,
Find attached a C++ ActiveX. Hope you can use this to verify your issue.
This is a very usefull ActiveX that will display the text MrWerksma.
Feel free to use this in any of you rprojects.
Good luck and a merry Christmas !
Frenk Mulder