473,549 Members | 3,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory leak advice needed

I use 3-d party component. In this component I must pass a reference to my
object. The problem is that this component has an ugly bug.When this
component is disposed, it incorrectly don't delete the reference to my
object from one of its shared lists.And since the operation repeats many
times the leak is huge.
Is there a way to kill my object anyway?
Thanks a lot,
Boni
Nov 23 '05 #1
13 1523
"Boni" <oilia@nospam > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I use 3-d party component. In this component I must pass a reference to my
object. The problem is that this component has an ugly bug.When this
component is disposed, it incorrectly don't delete the reference to my
object from one of its shared lists.And since the operation repeats many
times the leak is huge.
Is there a way to kill my object anyway?
Thanks a lot,
Boni


You should contact that 3rd party provider.... have you tried passing a
reference to Nothing? Depending on how that 3rd party component works,
passing a ref to Nothing may clear the circular dependency.... then again,
it may raise an error (which you should be able to trap)

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..
Nov 23 '05 #2
The 3-d party provider is Microsoft :). I am speeking about a memory leak
when I create a context menue items dynamically
(http://weblogs.asp.net/pwilson/archi...20/77451.aspx). They are not
disposed until the form is disposed.
It is documented bug and there is a workaround for that (using reflection).
But in general, somehow I don't see the reason of garbadge collection.
Before I started with it I was sure that it completely solve all memory leak
problems. But it seems, that it creates a new class of memory leak problems,
where you must think very much about all your references. And even then
there is no insurance that something went wrong because of 3-d party bugs.
I mean, .NET is a perfect libruary, easy to use. But the memory leak problem
should be revised once more. Currently there is even no appropriate software
which can automatically check those bug's (a-la bounds checker). For me
there was no problem to kill all created objects myself in c++. There are
coding guidlines and problem is quite managable. But in .NET I spend all my
time by looking for memory leaks, it is even more time then debugging. And I
am still not sure, when the debug level is acceptable.
Is it only my problem or all of you have it too?

"Ken Halter" <Ken_Halter@Use _Sparingly_Hotm ail.com> schrieb im Newsbeitrag
news:u4******** ******@tk2msftn gp13.phx.gbl...
"Boni" <oilia@nospam > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I use 3-d party component. In this component I must pass a reference to my
object. The problem is that this component has an ugly bug.When this
component is disposed, it incorrectly don't delete the reference to my
object from one of its shared lists.And since the operation repeats many
times the leak is huge.
Is there a way to kill my object anyway?
Thanks a lot,
Boni


You should contact that 3rd party provider.... have you tried passing a
reference to Nothing? Depending on how that 3rd party component works,
passing a ref to Nothing may clear the circular dependency.... then again,
it may raise an error (which you should be able to trap)

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..

Nov 23 '05 #3
I saw the fix below in one of the MIcrosoft articles for MainMenu (they
apparently can also have the same memory leak problems as Context Menus so I
would assume this fix would also apply them them as well but not sure)

For any forms that have MainMenu components, add the following code to make
sure the components are disposed of correctly:
Protected Override Sub Dispose(disposi ng as boolean)
If disposing
If not components is Nothing
components.Disp ose()
components = Nothing
If not mainMenu1 is Nothing
‘Code to add
mainMenu1.Dispo se()
mainMenu1 = Nothing
base.Dispose(di sposing)
End If
End If
End If

--
Dennis in Houston
"Boni" wrote:
The 3-d party provider is Microsoft :). I am speeking about a memory leak
when I create a context menue items dynamically
(http://weblogs.asp.net/pwilson/archi...20/77451.aspx). They are not
disposed until the form is disposed.
It is documented bug and there is a workaround for that (using reflection).
But in general, somehow I don't see the reason of garbadge collection.
Before I started with it I was sure that it completely solve all memory leak
problems. But it seems, that it creates a new class of memory leak problems,
where you must think very much about all your references. And even then
there is no insurance that something went wrong because of 3-d party bugs.
I mean, .NET is a perfect libruary, easy to use. But the memory leak problem
should be revised once more. Currently there is even no appropriate software
which can automatically check those bug's (a-la bounds checker). For me
there was no problem to kill all created objects myself in c++. There are
coding guidlines and problem is quite managable. But in .NET I spend all my
time by looking for memory leaks, it is even more time then debugging. And I
am still not sure, when the debug level is acceptable.
Is it only my problem or all of you have it too?

"Ken Halter" <Ken_Halter@Use _Sparingly_Hotm ail.com> schrieb im Newsbeitrag
news:u4******** ******@tk2msftn gp13.phx.gbl...
"Boni" <oilia@nospam > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I use 3-d party component. In this component I must pass a reference to my
object. The problem is that this component has an ugly bug.When this
component is disposed, it incorrectly don't delete the reference to my
object from one of its shared lists.And since the operation repeats many
times the leak is huge.
Is there a way to kill my object anyway?
Thanks a lot,
Boni


You should contact that 3rd party provider.... have you tried passing a
reference to Nothing? Depending on how that 3rd party component works,
passing a ref to Nothing may clear the circular dependency.... then again,
it may raise an error (which you should be able to trap)

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..


Nov 23 '05 #4
> The 3-d party provider is Microsoft :). I am speeking about a memory leak
when I create a context menue items dynamically


The logic below works for me with context menus built by my programs:

Dim cm As ContextMenu
' your code goes here to create cm including click event handler(s)
cm.Show(up to you, up to you)
Application.DoE vents() ' needed to raise and process the click event
cm.Dispose() ' required, else memory leak

Nov 23 '05 #5
Boni,

What do you think that dispose does?

Cor
Nov 23 '05 #6
Hi Amerser,
Why are u so sure? Have you checked with a profiler. This logic don't works
because of MS bug (in .NET 1.1.). There is still a static reference inside
of form (which you didn't created), but .NET did. So your cm will not be
disposed untill a form is disposed. Hope I don't disappoint you:). Take a
profiler and look yourself.
"AMercer" <AM*****@discus sions.microsoft .com> schrieb im Newsbeitrag
news:32******** *************** ***********@mic rosoft.com...
The 3-d party provider is Microsoft :). I am speeking about a memory leak
when I create a context menue items dynamically


The logic below works for me with context menus built by my programs:

Dim cm As ContextMenu
' your code goes here to create cm including click event handler(s)
cm.Show(up to you, up to you)
Application.DoE vents() ' needed to raise and process the click event
cm.Dispose() ' required, else memory leak

Nov 23 '05 #7
Wellcome in club you have the same memory leak, but you don't know about it.
"AMercer" <AM*****@discus sions.microsoft .com> schrieb im Newsbeitrag
news:32******** *************** ***********@mic rosoft.com...
The 3-d party provider is Microsoft :). I am speeking about a memory leak
when I create a context menue items dynamically


The logic below works for me with context menus built by my programs:

Dim cm As ContextMenu
' your code goes here to create cm including click event handler(s)
cm.Show(up to you, up to you)
Application.DoE vents() ' needed to raise and process the click event
cm.Dispose() ' required, else memory leak

Nov 23 '05 #8
Hi Cor, hi all,
I know about dispose and try to explicitely call it, but as you see, for
examle with context menus this don't prevent memory leak.
In general,my point is following.
IMHO it is much harder to find memory leaks in .NET. There are no tools for
this, and application don't crash. I miss a possibility to find such bugs.
(profiler can't really help if your app creates and disposed many objects,
you can't manually filter out correced objects from leaked objects. A have
programmed many years C++ and there are programming rules and tools which
allow to minimize memory leak (in my whole carrier the leak finding time was
not higher then a development time). But in .NET it is very hard to attack
memory leak problems. This is absolutely manual and time consuming process,
which kills .NET productivity win. The problem in .NET is even bigger
(IMHO), then in unmanaged code. If you don't deleted only 1 reference the
whole chain of objects can stay undeleted and you will even NOT notice it.
I think, that we need some possibility, at least to automatically detect
exact point of memory leaks. (but so far I have no idea how it would be
possible)
Are you agree with me or is it only my problem and nobody except me has it.
Thanks a lot for your opinions,
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb im Newsbeitrag
news:Of******** ******@TK2MSFTN GP11.phx.gbl...
Boni,

What do you think that dispose does?

Cor

Nov 23 '05 #9
Just a tip, when I suspect an object for memory leak, I do a simple program
to test it, within a for i as integer = 0 to 10000 or something, so you can
see if that is really the object causing the problem..
- Fredrik

"Boni" <oilia@nospam > wrote in message
news:O7******** ******@TK2MSFTN GP11.phx.gbl...
Hi Cor, hi all,
I know about dispose and try to explicitely call it, but as you see, for
examle with context menus this don't prevent memory leak.
In general,my point is following.
IMHO it is much harder to find memory leaks in .NET. There are no tools
for this, and application don't crash. I miss a possibility to find such
bugs. (profiler can't really help if your app creates and disposed many
objects, you can't manually filter out correced objects from leaked
objects. A have programmed many years C++ and there are programming rules
and tools which allow to minimize memory leak (in my whole carrier the
leak finding time was not higher then a development time). But in .NET it
is very hard to attack memory leak problems. This is absolutely manual and
time consuming process, which kills .NET productivity win. The problem in
.NET is even bigger (IMHO), then in unmanaged code. If you don't deleted
only 1 reference the whole chain of objects can stay undeleted and you
will even NOT notice it.
I think, that we need some possibility, at least to automatically detect
exact point of memory leaks. (but so far I have no idea how it would be
possible)
Are you agree with me or is it only my problem and nobody except me has
it.
Thanks a lot for your opinions,
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb im Newsbeitrag
news:Of******** ******@TK2MSFTN GP11.phx.gbl...
Boni,

What do you think that dispose does?

Cor


Nov 23 '05 #10

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

Similar topics

14
3236
by: J. Campbell | last post by:
what happens to allocated memory when a program terminates before the memory is released. For example: int main(){ int* array; int a_size = 1000; array = new int; for(int i = 0; i < a_size; ++i){ if(i > (a_size/2)) return 0; //oops...ended before delete...is this a problem?
1
1888
by: mark.engelberg | last post by:
I am having trouble identifying the source of a memory leak in a Windows Python program. The basic gist is as follows: 1. Generate a directed graph (approx. 1000 nodes). 2. Write the graph to a file. 3. Use the os.system command to invoke another program which processes the graph file (graphViz), and generates a gif image of the graph. 4....
8
3394
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? In nut shell, what is/are the realtion/s between the Memory Leak and Memory Corruption. Juts Theoritical Assumtion below:
19
1719
by: Jon Davis | last post by:
I'm reposting this because I really need some advice. I have a web app that makes many queries to the database on every page. In order to save development effort, I've consolidated all database querying to methods in a single static class, so whenever I need data, I pass a SQL string to a method and I am passed a datareader or else...
9
425
by: Anton | last post by:
{Willy Skjveland} Hi, how can I trace a Memory leak in aspnet_wp.exe? {Rheena} One moment please while I search it for you. It may take me a few moments {Willy Skjveland} I need to find out which application and which dll and asmx page that cause the problem. {Rheena} May I know what operating system you are using?
23
4520
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
3
5296
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". Anybody know anything about this? Does *Javascript* leak memeory, or does the *browser* leak memory?
27
2929
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do not delete a. try { a = new int ;
4
184
by: Christian Heimes | last post by:
Gabriel Genellina schrieb: Pure Python code can cause memory leaks. No, that's not a bug in the interpreter but the fault of the developer. For example code that messes around with stack frames and exception object can cause nasty reference leaks. Christian
0
7520
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.