Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
Search

Post Reply
12 posts • Page 1 of 2
User avatar
mwerksma
Posts: 19
Joined: Fri Jul 01, 2011 1:21 pm

Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

User avatar
tmalone
Posts: 192
Joined: Mon Nov 22, 2010 11:21 pm

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

User avatar
mwerksma
Posts: 19
Joined: Fri Jul 01, 2011 1:21 pm

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

User avatar
mwerksma
Posts: 19
Joined: Fri Jul 01, 2011 1:21 pm

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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.

User avatar
fmulder
Posts: 330
Joined: Wed Feb 03, 2010 9:46 am

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

User avatar
mwerksma
Posts: 19
Joined: Fri Jul 01, 2011 1:21 pm

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

User avatar
fmulder
Posts: 330
Joined: Wed Feb 03, 2010 9:46 am

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

User avatar
mwerksma
Posts: 19
Joined: Fri Jul 01, 2011 1:21 pm

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

User avatar
fmulder
Posts: 330
Joined: Wed Feb 03, 2010 9:46 am

Re: Dispose/cleanup an ActiveX in PVSS from panel\'s Terminate script

Post 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

Post Reply
12 posts • Page 1 of 2