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?
Printable View
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?
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?Quote:
Originally Posted by VaxoP
even strings/variables?Quote:
Originally Posted by MartinLiss
No, just created objects where you Set them, like Set MyObject As .... If you use forms in this app do you Unload them?
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.Quote:
Originally Posted by VaxoP
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.Quote:
Originally Posted by RhinoBull
I just have one form
and almost all my variables are local
dont those variables get destroyed once the sub is finished?
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.
If you have a timer on your form, would it be better to declare your variables locally, or globally?
-Sir Loin
Form level variables are maintained until the form is set to Nothing. Hoe are you handling the form. Open once and never close?Quote:
Originally Posted by VaxoP
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.Quote:
Originally Posted by MartinLiss
yep :bigyello:Quote:
Originally Posted by MartinLiss
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..Quote:
Originally Posted by dglienna
Then it must be some object that you are creating over and over without setting it to Nothing.Quote:
Originally Posted by VaxoP
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.
In case you still can't find any bugs in your memory handling, take a look at this:
http://www.vbaccelerator.com/home/VB...VB/article.aspObtain a Malloc object and try using the HeapMinimize call.
http://www.vbaccelerator.com/home/VB...lloc_in_VB.asp
Quote:
Minimizes the heap as much as possible by releasing unused memory to the operating system.
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......
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
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...
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.
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?
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
Can you zip up your code and attach it?
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.
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.
the thing is i have a array of like 700 winsocks.. can i do the same thing with a class?
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.