Debugging

  • Thread starter Thread starter Jon Vaughan
  • Start date Start date
J

Jon Vaughan

Hey,

I have a piece of code that is up and running fine, the code is used quite
heavily through out the day ( running full screen - borderless windows )
but randomly the code will kill its process and return to the desktop. The
reasons I can only think this may happen is bad memory usage / resource
management. Is this a likely cause ? and if it is how do you go about
debugging such a problem , its not something that can be solved with using
step into etc.

Thanks

Jon
 
After more research I have found that the code ( a program used in a garage
to keep track of jobs ) has what seems to be a memory leak, each time a job
is added about 5mb is added to the mem usage ( monitored through task
manager ). This value keeps going up as I have been testing it and I stopped
at 150mb, where I left the code hoping that the GC would sort it out. The
code was left for 15mins and when i came back the mem usage hadnt been
collected.

The code that im guessing is causing the increase are datasets that are used
and filled from sql server sprocs or local xml files. But the datasets are
disposed and the forms closed, so the memory should be released at some
point. So the question is, why hasnt the GC collected the 150mb ? surely its
wasted resource that at some point needs recycling ?

The other thing I noticed was that once I minimized the interface from
running full screen and then after a short period maximized it, the mem
usage was back doen to around 10mb. Is there some special case where
programs running full screen borderedless windows dont have garbage
collection , as this would seem very strange to me.

any ideas welcome as im stumped.

Jon
 
Jon,

First disposing does nothing if there is still a reference to it (beside
some processing).

By instance if you would do this strange code
Private mydatasets(1000) as dataset
Sub myprocedure
Static mycount
mydataset(mycount) = TheHugeDataset
myDataset(mycount).dispose
End sub

Than you are building a nice array of datasets in memory, which will stay,
until the program ends or when the object where that array is in goes out of
scope. That array is very small by the way, it holds only references to
those datasets.

If you do it like this
Sub myprocedure
dim ds as Dataset = TheHughDataset
End sub

Than ds is directly removed in the first fase of the GC. It goes out of
scope and there is no reference to it.

As well does looking in the taskmanager say nothing. It is not accurate, and
if there is enough memory, so what if that is used.

To get a better answer to your own problem, you have therefore to be more
precise how your code is working. The best with a sample (not your complete
program please)

In addition paste that than first in a notebook, copy it back and than in
the message, otherwise it is mostly complete unreadable and gets often no
answers.

I hope this helps something.

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