B
bw
I have a basic custom collection that throws a new
exception if the item(key) is not found in the collection.
This is used as part of a calling function. It all works
correctly, the problem (discovered using a memory
profiler) is that the base exception being thrown in the
collection is not being disposed of.
I understand about the GC etc etc. It appears that
something is hanging on to a reference to System.Exception
and a corresponding System.SByte[] (the exception
string??).
Can anyone tell me what is going on here? After a period
of time, this builds up to a significant amount of memory
being leaked!
I have heared of the problem in V1.0 of the framework,
where a similar problem occurs if you throw a new
exception from within a catch block. Maybe this is
similar? I am using V1.1 of the framework.
THANKS!
Sample code :
Public Class MYCollection : Inherits
Collections.DictionaryBase
...
Friend Function Item(ByVal Key As String) As Object
Item = MyBase.Dictionary.Item(Key)
If Item Is Nothing Then
Throw New System.Exception("This item does not
exist in the collection.")
End If
End Function
...
End Class
Friend Function funcGet(ByRef DocumentIndex As Integer) As
MyCLS
...
Try
funcGet = CType(MYCollection.Item("K" &
DocumentIndex), MyCLS)
If funcGet Is Nothing Then
Return Nothing
End If
Return funcGet
Catch
Return Nothing
End Try
End Function
exception if the item(key) is not found in the collection.
This is used as part of a calling function. It all works
correctly, the problem (discovered using a memory
profiler) is that the base exception being thrown in the
collection is not being disposed of.
I understand about the GC etc etc. It appears that
something is hanging on to a reference to System.Exception
and a corresponding System.SByte[] (the exception
string??).
Can anyone tell me what is going on here? After a period
of time, this builds up to a significant amount of memory
being leaked!
I have heared of the problem in V1.0 of the framework,
where a similar problem occurs if you throw a new
exception from within a catch block. Maybe this is
similar? I am using V1.1 of the framework.
THANKS!
Sample code :
Public Class MYCollection : Inherits
Collections.DictionaryBase
...
Friend Function Item(ByVal Key As String) As Object
Item = MyBase.Dictionary.Item(Key)
If Item Is Nothing Then
Throw New System.Exception("This item does not
exist in the collection.")
End If
End Function
...
End Class
Friend Function funcGet(ByRef DocumentIndex As Integer) As
MyCLS
...
Try
funcGet = CType(MYCollection.Item("K" &
DocumentIndex), MyCLS)
If funcGet Is Nothing Then
Return Nothing
End If
Return funcGet
Catch
Return Nothing
End Try
End Function