|
-
Aug 26th, 2005, 05:28 PM
#1
Thread Starter
Frenzied Member
My app just takes up more and more ram as time goes on
Reaching 5-600 mb in 3 hours
Its a chat server that has ~5000 users chatting on it in 3 hours
but the ram just goes higher and higher
i have no idea why, ive checked the code its tight as can be..
any suggestions?
-
Aug 26th, 2005, 05:39 PM
#2
Re: My app just takes up more and more ram as time goes on
 Originally Posted by VaxoP
...ive checked the code its tight as can be...
Unfortunately if that were true you wouldn't have a memory leak. Do you explicitly set all objects to Nothing when you are done with them?
-
Aug 26th, 2005, 05:41 PM
#3
Thread Starter
Frenzied Member
Re: My app just takes up more and more ram as time goes on
 Originally Posted by MartinLiss
Unfortunately if that were true you wouldn't have a memory leak. Do you explicitly set all objects to Nothing when you are done with them?
even strings/variables?
-
Aug 26th, 2005, 06:22 PM
#4
Re: My app just takes up more and more ram as time goes on
No, just created objects where you Set them, like Set MyObject As .... If you use forms in this app do you Unload them?
-
Aug 26th, 2005, 06:37 PM
#5
Re: My app just takes up more and more ram as time goes on
 Originally Posted by VaxoP
even strings/variables?
YES, YES and YES - if you don't need any of it then erase. Use local vars as much as you possible can. Use byte arrays in oppose to variants or strings if you can. Make sure you do explicitly declare string vars and not variants. Remomber that Dim abc, def, ghi As String will result in only GHI to be string variable and rest to be variants. And so on ... "Tight code" doesn't really mean much.
-
Aug 26th, 2005, 06:58 PM
#6
Re: My app just takes up more and more ram as time goes on
 Originally Posted by RhinoBull
YES, YES and YES - if you don't need any of it then erase. Use local vars as much as you possible can. Use byte arrays in oppose to variants or strings if you can. Make sure you do explicitly declare string vars and not variants. Remomber that Dim abc, def, ghi As String will result in only GHI to be string variable and rest to be variants. And so on ... "Tight code" doesn't really mean much.
While much of what you say are good practices, as long as you unload your forms and set them to Nothing, I don't think that variables of any type could lead to increasing memory use.
-
Aug 26th, 2005, 07:00 PM
#7
Thread Starter
Frenzied Member
Re: My app just takes up more and more ram as time goes on
I just have one form
and almost all my variables are local
dont those variables get destroyed once the sub is finished?
-
Aug 26th, 2005, 07:02 PM
#8
Re: My app just takes up more and more ram as time goes on
If you log a buffer or keep track of users who have disconnected (ie. whowas like on IRC), then make sure you erase old info every now and then.
-
Aug 26th, 2005, 07:02 PM
#9
Fanatic Member
Re: My app just takes up more and more ram as time goes on
If you have a timer on your form, would it be better to declare your variables locally, or globally?
-Sir Loin
-
Aug 26th, 2005, 07:20 PM
#10
Re: My app just takes up more and more ram as time goes on
 Originally Posted by VaxoP
I just have one form
and almost all my variables are local
dont those variables get destroyed once the sub is finished?
Form level variables are maintained until the form is set to Nothing. Hoe are you handling the form. Open once and never close?
-
Aug 26th, 2005, 07:22 PM
#11
Re: My app just takes up more and more ram as time goes on
 Originally Posted by MartinLiss
While much of what you say are good practices, as long as you unload your forms and set them to Nothing, I don't think that variables of any type could lead to increasing memory use.
Not always, Martin - static variables (especially object type) will remain in memory until you reset them which is one of the drawbacks of using them.
-
Aug 26th, 2005, 08:17 PM
#12
Thread Starter
Frenzied Member
Re: My app just takes up more and more ram as time goes on
 Originally Posted by MartinLiss
Form level variables are maintained until the form is set to Nothing. Hoe are you handling the form. Open once and never close?
yep
-
Aug 26th, 2005, 08:22 PM
#13
Re: My app just takes up more and more ram as time goes on
If you set your swap drive size to very small, wouldn't the app crash rather quickly (depending on your amount of RAM?)
-
Aug 27th, 2005, 07:56 PM
#14
Thread Starter
Frenzied Member
Re: My app just takes up more and more ram as time goes on
 Originally Posted by dglienna
If you set your swap drive size to very small, wouldn't the app crash rather quickly (depending on your amount of RAM?)
occasionally my app just closes for no reason..
-
Aug 27th, 2005, 09:27 PM
#15
Re: My app just takes up more and more ram as time goes on
 Originally Posted by VaxoP
yep 
Then it must be some object that you are creating over and over without setting it to Nothing.
-
Aug 27th, 2005, 09:29 PM
#16
Re: My app just takes up more and more ram as time goes on
Do you happen to use subclassing? Or do you use WinSock control or a custom class module for connections? Anyways, I think you should seriously debug and see which variables or arrays grow in size all the time.
-
Aug 28th, 2005, 02:04 AM
#17
Re: My app just takes up more and more ram as time goes on
In case you still can't find any bugs in your memory handling, take a look at this:
Obtain a Malloc object and try using the HeapMinimize call.
Minimizes the heap as much as possible by releasing unused memory to the operating system.
Last edited by penagate; Aug 28th, 2005 at 02:08 AM.
-
Aug 28th, 2005, 09:06 AM
#18
Fanatic Member
Re: My app just takes up more and more ram as time goes on
Just another thought. Are you using any third-party tools, Active-x controls etc?
Any commerically sold product should not have memory leaks, but it would not be the first time......
Brian
(Fighting with the RightToLeft bugs in VS 2005)
-
Aug 28th, 2005, 09:56 AM
#19
Re: My app just takes up more and more ram as time goes on
If its a chat server, with quite a bit of chat going on, wouldn't wherever the chat is (textbox/richtextbox) be using up alot of memory? Programs like mIRC delete certain bits of the oldest chat, which is why I assume this would be happening (after 3 hours or consistent chat).
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 28th, 2005, 09:58 AM
#20
Re: My app just takes up more and more ram as time goes on
Check also if you have Service Pack 6 for Visual Basic, if you don't, install it right away !
I had memory problems just like you, before Service Pack 6 came out...
-
Aug 28th, 2005, 11:53 AM
#21
Fanatic Member
Re: My app just takes up more and more ram as time goes on
If you are using the winsock control STOP doing that! It will cause the problem you are having, especially with extended use. There's some pretty good code around the board here for a pure socket replacment (maybe Rhino's code?) but if you have problems working with sockets perhaps this project will help you get those sorted out.
Also, as suggested by Merri, insure that any strings you are using are cleared occasionally - if a string exceeds it's max length it will result in an "out of memory" error.
If your program crashes without any error message being generated that suggest, to me anyway, either an an activex control hiccuping or, more likely, an API call which is experiencing an error. API calls have normally been the cuplrit when I've had programs die without any error message.
-
Aug 28th, 2005, 12:08 PM
#22
Re: My app just takes up more and more ram as time goes on
As you can see we can go on guessing what's wrong with your code until the cows come home and still don't give you the correct answer. It's impossible to debug a program which we haven't used or seen any code for. Is it the regular memory usage that increases or the VM size or perhaps the GDI objects? If the latter what kind of GDI APIs are you using? Are you using any other APIs from which you gain a handle of some sort and you never release?
-
Aug 28th, 2005, 10:33 PM
#23
Thread Starter
Frenzied Member
Re: My app just takes up more and more ram as time goes on
im not using any gdi objects
i just upgraded to sp6 (but the problem persists)
i AM using the winsock control
i clear the textbox that contains the chat data every few mins
i dont have many form level or public variables, most are just sub variables
i have no 3rd party tools
-
Aug 28th, 2005, 11:13 PM
#24
Re: My app just takes up more and more ram as time goes on
Can you zip up your code and attach it?
-
Aug 29th, 2005, 02:47 AM
#25
Fanatic Member
Re: My app just takes up more and more ram as time goes on
I'd vote for the winsock as being the culprit.
It used to be notorious for memory leaks - supposedly now fixed by MS, but who knows.
Brian
(Fighting with the RightToLeft bugs in VS 2005)
-
Aug 29th, 2005, 02:50 AM
#26
Re: My app just takes up more and more ram as time goes on
Are you using it from code or as a control. If it is from code then, when your memory usage is high, try destroying and reinstantiating the winsock class to see if that fixes your memory issue.
If your not using it from code (or if you can't do that... can't remember) try one of the Winsock classes available, I think there are some in the Codebank or elsewhere on the internet.
-
Aug 29th, 2005, 02:41 PM
#27
Thread Starter
Frenzied Member
Re: My app just takes up more and more ram as time goes on
the thing is i have a array of like 700 winsocks.. can i do the same thing with a class?
-
Aug 29th, 2005, 08:59 PM
#28
Re: My app just takes up more and more ram as time goes on
Holy bonanza! *tv theme tune starts playing*
That is for sure the reason you have troubles. You can do the same with a class, one class you could try is CSocketMaster from PSC.
You could also take a look into Pure IRCd which is very efficient IRCd server implementation on VB6. You might find some good ideas in it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|