• Welcome to Valhalla Legends Archive.
 

Memory Leaks

Started by Lenny, April 20, 2004, 08:23 PM

Previous topic - Next topic

Lenny

Is there anything in Visual Basic that can be done to solve this persistent problem in so many vb programs?

Perhaps some function that serves the same purpose as garbage collect in Java?  Something that could clear values in memory that no longer have a pointer?
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

MyndFyre

#1
A Garbage Collector isn't a language feature, it's a runtime feature.  People need to remember that Java isn't only a language, but a platform.  It might be dependent on other platforms, but it is still one in its own right.  People call Novell a Network Operating System (NOS), but it doesn't run on its own.

However, I recommend you upgrade to VB .NET.  You do get implicit garbage collection -- no extra work required.  This is based on the .NET Platform though -- it is not a part of VB 6 or older.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Grok

Quote from: Lenny on April 20, 2004, 08:23 PM
Is there anything in Visual Basic that can be done to solve this persistent problem in so many vb programs?

Perhaps some function that serves the same purpose as garbage collect in Java?  Something that could clear values in memory that no longer have a pointer?

VB6 Memory Leaks?  Do tell!  Show me how you are creating these.

Lenny

After a long period of running my VB programs, they seem to build up more and more memory usage...Much faster than any other non vb programs....

I'm not storing any variables that consistently get larger and larger as time goes by, I assumed the large usage was due to storing values that are no longer used.....
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Tuberload

Quote from: Lenny on April 20, 2004, 09:36 PM
After a long period of running my VB programs, they seem to build up more and more memory usage...Much faster than any other non vb programs....

I'm not storing any variables that consistently get larger and larger as time goes by, I assumed the large usage was due to storing values that are no longer used.....

Do you ever clear the rtb that stores the data recieved from battle.net? This was the main reason my bot took up so much memory. (When I programmed in VB that is)
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

Lenny

Actually, yes, my bot automatically removes the oldest lines of text once it reaches a user defined limit...
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Tuberload

Quote from: Lenny on April 20, 2004, 10:06 PM
Actually, yes, my bot automatically removes the oldest lines of text once it reaches a user defined limit...

Geez, didn't mean to suggest something you're already doing. Next time I won't offer any help.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

Lenny

That reply didnt seem hostile at all...
I was just mentioning it shouldnt be one of the causes of the growing memory usage...
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Grok

Quote from: Lenny on April 20, 2004, 11:16 PM
That reply didnt seem hostile at all...
I was just mentioning it shouldnt be one of the causes of the growing memory usage...

So run it in debug mode and break out after a few hours to see what is taking up so much memory?  Try your local variables window, for starters.  I think it shows globals too.

Tuberload

Quote from: Lenny on April 20, 2004, 11:16 PM
That reply didnt seem hostile at all...
I was just mentioning it shouldnt be one of the causes of the growing memory usage...

I didn't say it sounded hostile, you just sounded offended I would even bring that up.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

Adron

Quote from: Grok on April 20, 2004, 09:05 PM
VB6 Memory Leaks?  Do tell!  Show me how you are creating these.

You can easily create memory leaks in VB. All you have to do is make some objects that reference each other and then drop your own references to them.

iago

hmm, incidentally, I'm going to move this to VB forum
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Telos

Ive found that if youre optimizing your VB programs for memory usage encapsulating everything in classes is the best way to go but you incur a performance penalty for adding a layer of abstraction.  The other thing I do is to explicitly remove references to class objects when Im through this way I dont end up with looped objects as Adron described

Grok

#13
Quote from: Adron on April 21, 2004, 05:07 AM
Quote from: Grok on April 20, 2004, 09:05 PM
VB6 Memory Leaks?  Do tell!  Show me how you are creating these.

You can easily create memory leaks in VB. All you have to do is make some objects that reference each other and then drop your own references to them.

What's so easy about it?
Dim objX As Object, objX1 As Object, objX2 As Object
Dim intMod2 As Integer
For lPos = 1 To 100
   Set objX = CreateObject("Project.Class")
   intMod2 = lPos Mod 2
   If intMod2 = 1 Then
       Set objX1 = objX
   Else
       Set objX2 = objX
       Set objX1.otherguy = objX2
       Set objX2.otherguy = objX1
   End If
Next lPos
Set objX1 = Nothing
Set objX2 = Nothing


You have to get pretty sloppy to do that?

Eric

#14
Quote from: Lenny on April 20, 2004, 09:36 PM
After a long period of running my VB programs, they seem to build up more and more memory usage...Much faster than any other non vb programs....

I've ran my Visual Basic-made programs for weeks at a time without experiencing any problems.