Explicit disposing of connected rapid obj
Hi,
If a "ABB.Robotics.Controllers.RapidDomain.Rapid" object is set to the "Rapid" property of a "ABB.Robotics.Controllers.Controller" object, and the controller object is later disposed using "Dispose()", will the rapid object need to be explicitly disposed or will it be automatically set to null?:
Controller1 = new ABB.Robotics.Controllers.Controller();
RapidDomain1 = Controller1.Rapid;
:
:
:
if(Controller1 != null)
{
Controller1.Dispose();
Controller1 = null;
}
// IS THIS NEXT CODE REQUIRED? IS IT DANGEROUS?
if(RapidDomain1 != null)
{
RapidDomain1.Dispose();
RapidDomain1 = null;
}
Thanks.
Technical Support Engineer
Robotics Product & Systems Service
Manufacturing Automation, Automation Technologies (ATMA)
ABB Australia
Email: michael.siminski @ au.abb.com
Comments
-
The controller.Rapid object will be disposed when the controller object is disposed. You do not need to and should not dispose it explicitly.Urban Vikblom
CONTAB0 -
Hello,
If I follow the user guide's examples, then I'm told that I should dispose the Rapid also explicitly. In my application I also dispose the Rapid explicitly.
What am I suppose to do?
Regards,
Jan-Jaap0 -
My approach is to explicitly dispose of all FPSDK objects (that implement dispose) that I use once I have finished with them.Russell Drown0
-
In my original example, if "RapidDomain1" and "Controller1.Rapid" both reference the same object (ie there is only one object but referenced by two variables), then this object should surely only be disposed once.
If, however, when obtaining "Controller1.Rapid", a copy of the object is made (ie if there are actually two objects), then both would need to be disposed explicitly.
I'm not sure which situation is the case?
Thanks.
Michael Siminski
Technical Support Engineer
Robotics Product & Systems Service
Manufacturing Automation, Automation Technologies (ATMA)
ABB Australia
Email: michael.siminski @ au.abb.com0 -
Russ is right that all objects that implements the Dispose method should be disposed explicitly. In the case of the objects that are accessed through the Controller object via properties the dispose of these objects are done in the controller object. This is valid from the 5.05 release of the FPSDK (not 5.04). I don't think this is a problem as long as you do not use the rapid object after you have disposed the controller.
I now always use "this.aController.Rapid.GetRapidData(...)" and do not use the shortcut.
I'm aware that I didn't answer the last question, but it is reasonable to think that there is two .NET objects with one COM object both reference. The question is whether the the dispose deletes the COM object or if a check is done to see if more than one managed object references the COM object. This is a question for the developers and I can hope they look in this forum?
Urban Vikblom
CONTAB0 -
I got a confirmation that the dispose should always be done as Russ said and doesn't hurt even if you call it first on the Rapid object and then on the controller. When it comes to the controller object its dispose removes all references to the COM object. So, Michael, the code you do is OK, but you should switch the code so that the Rapid object is disposed first and then the controller. Not until the controller is disposed is the Rapid object "really" removed from memory.
Jan-Jaap, dispose the Rapid object, but make sure you do it before you dispose the controller object. If that order is not followed in the UserGuide then the UserGuide is wrong!
Update: The above is only valid for 5.07 release of the SDK. For the 5.06 release do not dispose the Rapid, IOSystem, LogEvent and FileSystem object separately from the Controller object. If you do, you will have to dispose the Controller object and create it again to access these object domains.
Urban38660,3665277778Urban Vikblom
CONTAB0 -
Hello,
I ran into some new problems with the disposal of my FP application. My application contains some buttons with icons, a tabcontrol with 2 pages, a numpad, some alphapads, 5 rapiddata's and 1 controller. Currently, what I do is:
dispose the alphapad after use;
dispose other items in the sub dispose in the following order: rapiddata's, buttons, numpad, tabpages, tabcontrol, RC, mainpanel.
Now, if I try to close the application, the window disappears, but in the taskbar, it is still vissible. If I click the taskbar, the application reappears on screen. No errors seem to occur, no exceptions. I did some experiments with the order of the disposal, leaving out some items etc., but nothing seems to help.
As far as I remember, the problems seem to have started when I introduced the tabcontrol. Can it have something to do with the GTPUMasterDialog? Or something else I've forgotten?
Regards,
Jan-Jaap0 -
You use only one main view, right? Have you overriden ActionItem_Click or CancelItem_Click? You added the TabPages to the TabControls TabPages collection? Show the Dispose method, please.
Urban Vikblom
CONTAB0 -
Hello,
I have one main view and don't know what you mean by the overriden.
The tabpages:
Me.TabControl1 = New TabControl
Me.pHoofd = New TabPage
Me.pInvoer = New TabPage
Me.TabControl1.TabPages.Add(Me.pHoofd)
Me.TabControl1.TabPages.Add(Me.pInvoer)
Me.MainPanel.Controls.Add(Me.TabControl1)
The dispose sub:
If Not IsDisposed Then
If disposing Then
'rapid data
If Not RD Is Nothing Then
RD.Dispose()
RD = Nothing
End If
If Not RDpt Is Nothing Then
RDpt.Dispose()
RDpt = Nothing
End If
If Not RDeob Is Nothing Then
RDeob.Dispose()
RDeob = Nothing
End If
If Not RDstatus Is Nothing Then
RDstatus.Dispose()
RDstatus = Nothing
End If
'hoofd
If Not RDCurStat Is Nothing Then
RDstatus.Dispose()
RDstatus = Nothing
End If
If Not bEnd1 Is Nothing Then
bEnd1.Dispose()
bEnd1 = Nothing
End If
'buttons
If Not bEnd2 Is Nothing Then
bEnd2.Dispose()
bEnd2 = Nothing
End If
'invoer
If Not bLoad1 Is Nothing Then
bLoad1.Dispose()
bLoad1 = Nothing
End If
If Not bLoad2 Is Nothing Then
bLoad2.Dispose()
bLoad2 = Nothing
End If
If Not bStationsInv Is Nothing Then
bStationsInv.Dispose()
bStationsInv = Nothing
End If
If Not bStationsHo Is Nothing Then
bStationsHo.Dispose()
bStationsHo = Nothing
End If
If Not numPad1 Is Nothing Then
numPad1.Dispose()
numPad1 = Nothing
End If
'tabpages
If Not pHoofd Is Nothing Then
pHoofd.Dispose()
pHoofd = Nothing
End If
If Not pInvoer Is Nothing Then
pInvoer.Dispose()
pInvoer = Nothing
End If
If Not TabControl1 Is Nothing Then
TabControl1.Dispose()
TabControl1 = Nothing
End If
If Not TheRC Is Nothing Then
TheRC.Dispose()
TheRC = Nothing
End If
If Not MainPanel Is Nothing Then
MainPanel.Dispose()
MainPanel = Nothing
End If
End If
MyBase.Dispose(disposing)
End IfHope this makes it clearer
Regards,
Jan-Jaap0 -
Remove dispose of MainPanel. That is the job of GTPUMasterDialog disposal.
Urban Vikblom
CONTAB0 -
I tried that, but it does not help much. The reason I entered it was to see if I perhaps had forgotten this one.Regards,
Jan-Jaap0 -
I dont't think this is the problem, but...
If Not RDCurStat Is Nothing Then
RDstatus.Dispose() <- Copy-paste issue
RDstatus = Nothing
End IfUrban Vikblom
CONTAB0 -
Hello,
Thanks, that was the problem indeed.
It's usually the little you things that you miss after staring a few hours
Regards,
Jan-Jaap0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings