- Agent
- C:\svn\roboresc\2011\competition\Agent\Agent\Agent.vb(1035): Dim seedPose As New Pose2D(0, 0, 0)
Using seedPose As New Pose2D(0, 0, 0) gives error: Pose2D must implement System.IDisposable
seedPose.Dispose() gives error: not a member of Pose2D
Tried for the moment seedPose = Nothing (ProcessGroundTruthData not active during competition)
- C:\svn\roboresc\2011\competition\Agent\Agent\Agent.vb(1077): Dim cmd As New StringBuilder()
Same problem: used cmd = Nothing
- C:\svn\roboresc\2011\competition\Agent\Agent\Agent.vb(1314): Dim dict As New Specialized.StringDictionary
The dict is returned by the function ToDictionary. Seems to be never used.
The function calls ToKeyValuePair, which also makes new objects. This function is heavily used in line-parsing
- C:\svn\roboresc\2011\competition\Agent\Agent\Agent.vb(1767): Dim cm As Imaging.ColorMatrix = New Imaging.ColorMatrix(New Single()() _
Could be heavy function, with many nested New-calls. Explicitly made it Nothing
- CommAgent.vb
- C:\svn\roboresc\2011\competition\Agent\Agent\CommAgent.vb(163): Dim iFrontier As New List(Of Integer)
Added: iFrontier.Clear() iFrontier = Nothing
Did the same for iHistory & iNextFrontier
- C:\svn\roboresc\2011\competition\Agent\Agent\CommAgent.vb(367): Dim combination As New Vector2(operatorDistance, pathloss)
Finally an object which is nicely disposed!
- C:\svn\roboresc\2011\competition\Agent\Agent\CommAgent.vb(414): Dim combination As New Vector2(distance, Me.CommActor.GetSignalStrengthToOperator(Me.Name) + attenuation)
Yet, this is not truth for the next one. Added: combination = Nothing
- WorldView
- C:\svn\roboresc\2011\competition\Agent\Agent\WorldView.vb(23): Return New ManifoldImage(manifold, UvARescue.Tools.Constants.MAP_RESOLUTION, False)
Check calls: only once per Agent
- AvoidTeamMate
- C:\svn\roboresc\2011\competition\Agent\Behavior\Motions\AvoidTeamMate.vb(62): Dim avoidRobotPose As Pose2D = New Pose2D 'Pose2D of robot to be avoided
Added: voidRobotPose = Nothing
- AvoidVictim
- C:\svn\roboresc\2011\competition\Agent\Behavior\Motions\AvoidTeamMate.vb(62): Dim avoidRobotPose As Pose2D = New Pose2D 'Pose2D of robot to be avoided
Added: pglobal = Nothing
- CorridorWalk
- C:\svn\roboresc\2011\competition\Agent\Behavior\Motions\CorridorWalk.vb(119): Dim pglobal As Vector2 = New Pose2D(CType(part.X * factor, Single), CType(part.Y * factor, Single), 0).ToGlobal(pose).Position
Added: pglobal = Nothing
- TcpCameraConnection
- ReceiveImageData (VS Memory Profiler indicates most heavy memory usage UsarCommander)
- Added buffer=Nothing after BlockCopy
- LiveDriver
- Line 214: Dim msgs As Specialized.StringCollection = Me._UsarSimConnection.ReceiveMessages(4096)
is Most used data structure (String)
Added msgs = Nothing
- Line 313: Dim bytes As Byte() = Me._ImageServerConnection.ReceiveImageData(921610)
ReceiveImageData uses 60% of UsarClients memory. It makes a curimg object and returns it. Added bytes = Nothing
-
Also looked at usage of Dispose.
- TcpConnection has an stream GetStream and does nicely stream.Dispose
- MapInfo
- C:\svn\roboresc\2011\competition\Tools\MapInfo\MapInfo.vb(602): Public Sub Dispose() Implements IDisposable.Dispose
Function has two TODO's: Added Me._Points.ClearData()
Me._LineStrings.ClearData()
- Class calls ogr.RegisterAll, but didn't see any unregister.
Memory Analyzer shows a huge allocation for
ICSharpCode.SharpZipLib.BZip2.BZip2OutputStream.StackElement.
Yet, this OutputStream is used on only two places, and nicely protected with Using.
- WSSConversation
- Receive() contains several objects which are not explicitly are given free.
Added several = nothings (Tested with 2nd UsarCommander profile, code is still functional)
- Lek zit toch vooral in UsarClient.
Conclusion Rev. 2266
Many modifications to find memory leak:
* Initially UsarCommander used 13 Gb of memory, after this commit 1Gb of memory
* buffer=Nothing after BlockCopy in ReceiveImageData reduced the memory usage from 90 to 50
* Operator is not longer making connection to ImageServer: 50% less memory usage, main usage (971 Kb) in WssConversation:ReceiveMessage
* Initially UsarClient used 7.4 Gb of memory, after this commit 3 Gb
* Half of the memory (1.4 Gb) is also in WssConversation:ReceiveMessage, the other half in LiveDriver.Run (1.3 Gb)