• Welcome to Valhalla Legends Archive.
 

RAM Usage Help Needed

Started by Anubis, June 30, 2004, 06:49 PM

Previous topic - Next topic

Dyndrilliac

Quote from: Networks on July 02, 2004, 10:18 AMAnubis why don't you put Option Explicit on top all your modules, classes, and forms, then run the program and you'll notice all the variables you haven't declared and missed.

That's more of error debugging then anything else.

What I did was make sure I unloaded and cleared all the objects I could in my programs after they would no longer be used. I made built in functions that would run when the program was idle to clear data and unload uneeded objects, made all my "" = vbNullString, all my " " = Space(1), and tried to use Longs as sparingly as possible.

Also use API over user made functions whenever possible. If you find yourself using lots of nested If/Then/Else statements, and it's basically choosing from multiple cases for a condition, convert those to Select Case statements. Also, use Loops instead of GoTo whenever possible.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Networks

Even if it is more debugging it will still help him to make sure ALL his variables are declared saving RAM right?

Banana fanna fo fanna

Yeah, variants are something ridiculously huge iirc.

Stealth

64 bytes freshly-initialized.
- Stealth
Author of StealthBot

The-FooL

With multiple instances of a class module, I assume it doesn't reload all the functions does it?  So if I had a class with a lot of functions and loaded two of them, would it take double the memory?  The reason I'm asking this is because I have some very extensive class modules in my programs.

Grok

Quote from: The-FooL on July 15, 2004, 07:47 AM
With multiple instances of a class module, I assume it doesn't reload all the functions does it?  So if I had a class with a lot of functions and loaded two of them, would it take double the memory?  The reason I'm asking this is because I have some very extensive class modules in my programs.

The code is loaded once.  The data areas are created for each instance of your class.

If you load a class 10 times, the code will be in memory once, but you will have 10 data areas for the class data.

Maddox

There really is no difference between the memory required for a module and class module with the same implementation. If anything, the class takes a little more memory ( a few bytes ) to create a vtable for each instance of a class.

Like Grok said, your code is only in memory once, so freeing memory associated with a class because it has too many functions that are rarely used is not going to do much in terms of lowering your ram usage.

If you want to save memory then you should try to streamline your applications as best you can. Try to use as little amount of variables and code as possible. Clearing old text in text boxes can save a lot of memory as well.
asdf.

MyndFyre

Quote from: UserLoser. on July 01, 2004, 11:40 AM
Quote from: Anubis on June 30, 2004, 06:49 PM
Most of the programs I make end up using a LOT of RAM and do hardly anything. The bot I've been working on lately has hardly anything in it and it uses over 8MB of RAM. y only question is what can I do / should I not do to lower this. Some API I should or shouldn't use, ActiveX control maybe? I've declared all variables that I've used (such as Dim i As Integer) and all variables have been delcared at the beginning of the functions...

Any help is much appreciated, thanks.

Do everything that VB sucks at in a DLL written in C++

Such as Newby, who decided that the Winsock control sucked, so he created a wrapper DLL in C that had a function that called a wrapper function to call send().
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.

Newby

Hurr, I was told it was a dumb idea so I removed it. :( :P
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

hismajesty

Quote from: Myndfyre on July 19, 2004, 09:04 PM
Quote from: UserLoser. on July 01, 2004, 11:40 AM
Quote from: Anubis on June 30, 2004, 06:49 PM
Most of the programs I make end up using a LOT of RAM and do hardly anything. The bot I've been working on lately has hardly anything in it and it uses over 8MB of RAM. y only question is what can I do / should I not do to lower this. Some API I should or shouldn't use, ActiveX control maybe? I've declared all variables that I've used (such as Dim i As Integer) and all variables have been delcared at the beginning of the functions...

Any help is much appreciated, thanks.

Do everything that VB sucks at in a DLL written in C++

Such as Newby, who decided that the Winsock control sucked, so he created a wrapper DLL in C that had a function that called a wrapper function to call send().

Haha, not only is the idea silly..so is the way it sounds when said verbally. :P

Grok

Pretty good idea, actually.  That sounds like a terrific way to learn to write a decent, reliable library, one you would use yourself.  At the same time, learning how an API works behind a commonly used ActiveX control (WinSock.dll).

Eric

#26
QuoteAlso use API over user made functions whenever possible.
Overuse of API calls can be a bad thing.

MyndFyre

Quote from: LoRd[nK] on July 19, 2004, 10:41 PM
QuoteAlso use API over user made functions whenever possible.
Overuse of API calls can be a bad thing.

Unless all you do is consistently access wrappers to those API calls, in which case you'll likely reduce memory costs and increase speed by taking that level of indirection out.
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.

Banana fanna fo fanna

At the same time, destroying what VB is good at, and increasing your development time.

Just code efficiently, and write speed-intensive portions in DLLs.