finding memoryleak

  • Thread starter Thread starter LS
  • Start date Start date
L

LS

I have consoleapplication which is always running fine for serval weeks
until I get an "out of memory exception"
I thougth the dotnet framework was supposed to handle my bad programming :)
What is the best method to find this memoryleak?

Regards

Geert
 
Geert,

Can you show a little piece of your code.

(How do you instance by example objects and values)

Cor
 
Can you show a little piece of your code.euh, the program is rather long:
I think I do it the way it should be.

I always do

dim blabla as someobject

And at the end

blabla.dispose
 
Where do you do this,
Because not everybody does that the same
At the beginning of the function/method.
Can you give me an example of how to do it good and bad.
Anyhow isn't dotnet supposed to do garbagecollection?
 
LS,

In my opinion is this very bad
private a as arraylist
private b as new object
Sub C
a = new arraylist
a.add(b)
End sub

I did not test it if there is some extra intelligence, however I assume that
all those new created arraylist stay until the end of the program because
they have all a reference to b.

Sub D
dim a as new arraylist
dim b as new object
a.add(b)
End sub

Here you are sure that all goes out of scope and by the objects used memory
will be released by the GC. However this last one is not always possible of
course.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top