PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
GetManifestResourceStream Memory Leak ?
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
GetManifestResourceStream Memory Leak ?
![]() |
GetManifestResourceStream Memory Leak ? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi All,
I have a graphic on screen that I load from an embedded resource. Under certain conditions I want this icon to flash - so I have two icons that I switch between using a timer (this fires every half a second)... the code just loads a different bitmap from a resource and sets the PictureBox.Image as required. This all works fine except for one issue - the amount of free memory on the PDA seems to keep dropping continuously until over 1MB has been used up.. then seems to stop. The GIF image I'm loading is only 8Kb. By elimination (i.e. commenting it everything except one line) I've traced the problem to the actual GetManifestResourceStream call. Any suggestions are welcome as memory is a precious commodity on PDAs!! The code is as follows (I've tried to be very explicit about closing and destroying everything )Public Sub ChangeHighlightForSelectedIcon(ByRef oCurrentPictureBox As PictureBox, _ ByVal eHighlightState As enumHighlightState, _ ByVal eCurrentScreenSettings As enumScreenSettings) : : < code here to setup etc.. omitted as not part of the problem > : : : oCurrentAssembly = [Assembly].GetExecutingAssembly() oBitmapStream = oCurrentAssembly.GetManifestResourceStream(ROOT_NAMESPACE & "." & sNewBMPIcon) 'Load bitmap from stream. oTempIcon = New Bitmap(oBitmapStream) If oCurrentPictureBox.Image IsNot Nothing Then oCurrentPictureBox.Image.Dispose() oCurrentPictureBox.Image = Nothing End If oCurrentPictureBox.Image = CType(oTempIcon.Clone, Image) oCurrentPictureBox.Refresh() Catch ex As Exception 'Required if bitmap does no exist as an embedded resource. Finally If oBitmapStream IsNot Nothing Then oBitmapStream.Flush() oBitmapStream.Close() oBitmapStream = Nothing End If If oTempIcon IsNot Nothing Then oTempIcon.Dispose() oTempIcon = Nothing End If If oCurrentAssembly IsNot Nothing Then oCurrentAssembly = Nothing End If sNewBMPIcon = Nothing End Try End Sub |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 
)
