473,395 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Undisposed instances of BinaryReader in localized forms

I've been trying out the .NET Memory Profiler
(http://www.scitech.se/memprofiler/) and I found an excessive number of
undisposed instances of BinaryReader after opening and then closing various
forms. The thing that these forms have in common is that they are localized
for both English and Dutch. I tried adding resources.ReleaseAllResources()
from the destructor but that had no effect. I'm pretty sure that it is the
localization code but of course I'm not totally sure, does anyone have any
more information about this, or perhaps what I can do to dispose all of the
BinaryReader instances? This application is designed to run 24/7 from the
system tray so its important to me to patch up any memory leaks.

Thanks,
Robert
Nov 16 '05 #1
4 1842
Hi Robert

You should not leave any release/free work to destructors!

The best way to keep resources free is to Close (eventually Dispose)
every Reader/Stream after its job is done.
If there are more instances of BinaryReader then you should keep
references of unclosed ones (in Array or List) till they will be
Closed.

Regards

Marcin

PS: You should close reader/stream in "finally" block.in case of
exception
I've been trying out the .NET Memory Profiler
(http://www.scitech.se/memprofiler/) and I found an excessive number of
undisposed instances of BinaryReader after opening and then closing various
forms. The thing that these forms have in common is that they are localized
for both English and Dutch. I tried adding resources.ReleaseAllResources()
from the destructor but that had no effect. I'm pretty sure that it is the
localization code but of course I'm not totally sure, does anyone have any
more information about this, or perhaps what I can do to dispose all of the
BinaryReader instances? This application is designed to run 24/7 from the
system tray so its important to me to patch up any memory leaks.

Thanks,
Robert

Nov 16 '05 #2
Hi Marcin-

Perhaps I should have clarified that BinaryReader isn't directly called
anywhere in my code - I'm assuming that the Windows
Form Designer localization code (from ResourceManager) is calling it.

Robert
"Marcin Grzębski" <mg*******@taxussi.no.com.spam.pl> wrote in message
news:cd**********@atlantis.news.tpi.pl...
Hi Robert

You should not leave any release/free work to destructors!

The best way to keep resources free is to Close (eventually Dispose)
every Reader/Stream after its job is done.
If there are more instances of BinaryReader then you should keep
references of unclosed ones (in Array or List) till they will be
Closed.

Regards

Marcin

PS: You should close reader/stream in "finally" block.in case of
exception
I've been trying out the .NET Memory Profiler
(http://www.scitech.se/memprofiler/) and I found an excessive number of
undisposed instances of BinaryReader after opening and then closing various forms. The thing that these forms have in common is that they are localized for both English and Dutch. I tried adding resources.ReleaseAllResources() from the destructor but that had no effect. I'm pretty sure that it is the localization code but of course I'm not totally sure, does anyone have any more information about this, or perhaps what I can do to dispose all of the BinaryReader instances? This application is designed to run 24/7 from the system tray so its important to me to patch up any memory leaks.

Thanks,
Robert

Nov 16 '05 #3
Hi Robert,

It looks like another .NET internal problem.

"ReleaseAllResources()" should work... but you'll never know.

hmmm... I can only recommend to get resources from out of
"InitializeComponent()" in contructor ( TODO block ).
Then release them by "ReleaseAllResources()" at the end of
constructor.

If you are initializing more forms/controls/components then don't
forget to dispose them one by one at "the end".

Marcin

PS: Do you have memory-taking resources? Text & icons or
more?
Hi Marcin-

Perhaps I should have clarified that BinaryReader isn't directly called
anywhere in my code - I'm assuming that the Windows
Form Designer localization code (from ResourceManager) is calling it.

Robert
"Marcin Grzębski" <mg*******@taxussi.no.com.spam.pl> wrote in message
news:cd**********@atlantis.news.tpi.pl...
Hi Robert

You should not leave any release/free work to destructors!

The best way to keep resources free is to Close (eventually Dispose)
every Reader/Stream after its job is done.
If there are more instances of BinaryReader then you should keep
references of unclosed ones (in Array or List) till they will be
Closed.

Regards

Marcin

PS: You should close reader/stream in "finally" block.in case of
exception

I've been trying out the .NET Memory Profiler
(http://www.scitech.se/memprofiler/) and I found an excessive number of
undisposed instances of BinaryReader after opening and then closing
various
forms. The thing that these forms have in common is that they are
localized
for both English and Dutch. I tried adding
resources.ReleaseAllResources()
from the destructor but that had no effect. I'm pretty sure that it is
the
localization code but of course I'm not totally sure, does anyone have
any
more information about this, or perhaps what I can do to dispose all of
the
BinaryReader instances? This application is designed to run 24/7 from
the
system tray so its important to me to patch up any memory leaks.

Thanks,
Robert


Nov 16 '05 #4
Hi Marcin-

Yes, I've tried using ReleaseAllResources at the end of
InitializeComponent - but it didn't solve the BinaryReader problem. There
are quite a few memory-taking resources in the program, but I've taken a lot
of care to ensure that they're Disposed after they've been used.

Robert
"Marcin Grzębski" <mg*******@taxussi.no.com.spam.pl> wrote in message
news:cd**********@atlantis.news.tpi.pl...
Hi Robert,

It looks like another .NET internal problem.

"ReleaseAllResources()" should work... but you'll never know.

hmmm... I can only recommend to get resources from out of
"InitializeComponent()" in contructor ( TODO block ).
Then release them by "ReleaseAllResources()" at the end of
constructor.

If you are initializing more forms/controls/components then don't
forget to dispose them one by one at "the end".

Marcin

PS: Do you have memory-taking resources? Text & icons or
more?
Hi Marcin-

Perhaps I should have clarified that BinaryReader isn't directly called
anywhere in my code - I'm assuming that the Windows
Form Designer localization code (from ResourceManager) is calling it.

Robert
"Marcin Grzębski" <mg*******@taxussi.no.com.spam.pl> wrote in message
news:cd**********@atlantis.news.tpi.pl...
Hi Robert

You should not leave any release/free work to destructors!

The best way to keep resources free is to Close (eventually Dispose)
every Reader/Stream after its job is done.
If there are more instances of BinaryReader then you should keep
references of unclosed ones (in Array or List) till they will be
Closed.

Regards

Marcin

PS: You should close reader/stream in "finally" block.in case of
exception
I've been trying out the .NET Memory Profiler
(http://www.scitech.se/memprofiler/) and I found an excessive number of
undisposed instances of BinaryReader after opening and then closing


various
forms. The thing that these forms have in common is that they are


localized
for both English and Dutch. I tried adding


resources.ReleaseAllResources()
from the destructor but that had no effect. I'm pretty sure that it is


the
localization code but of course I'm not totally sure, does anyone have


any
more information about this, or perhaps what I can do to dispose all of


the
BinaryReader instances? This application is designed to run 24/7 from


the
system tray so its important to me to patch up any memory leaks.

Thanks,
Robert


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tonya | last post by:
Hi, Does anyone have any example of how i can manage forms in my application?? I want to be able to reference my form instances that are currently open from other forms. why cant i open...
1
by: Bogdan Zamfir | last post by:
Hi, I have big troubles with an Access2002 application I wrote it under Acc2002 Romanian, and try to run it on Acc2002 US version, and I have the following troubles For some forms, Load event...
0
by: Robert Misiak | last post by:
Hi all- I'm trying to add Windows 98/ME support to an app that previously only supported Windows 2000+. My test box is a running 98 SE. I have a number of localized forms (translated for...
1
by: Bob | last post by:
I had developped a class in Vs2003 Vb.net that would give me localized project ressources (not form ressources, these were in the individual forms). I had two files MyProjectResources.resx and...
1
by: cold80 | last post by:
I'm trying to understand how VS 2005 and the .NET Framework 2.0 can be used for a localized application. I've read a lot of messages, posts and guides but I can find a straight answer. I would like...
0
by: Joe | last post by:
Hi, what circumstances can lead to the situation (I currently have this situation, but I don't know why...) that the list of Localized Resources outputs (in a VS 2005 setup project, in the File...
5
by: Neil | last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com... Question for you. I'm doing something similar, only, instead of opening...
1
by: Jon Slaughter | last post by:
Can one extend the type itself and not just an instance of the type? So I have something, say, like public static DateTime RawRead(this DateTime i, Stream s) { BinaryReader b = new...
10
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= | last post by:
using(BinaryReader reader = new BinaryReader(new FileStream(filePathName, FileMode.Open))) { //do something here } I have seen this code in one of the discussion forum. In this will file stream...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.