Register for your free account! | Forgot your password?

You last visited: Today at 01:05

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Memory Leak?

Discussion on Memory Leak? within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
Memory Leak?

Ok guys...3rd thread about this....
Q1: Does the variables that are declared like int x = new int(); use memory if not set to null after it's no longer used?
Q2:is there a way to delete a variable if it's no longer used?
Q3:is it of any use to set the variables/arrays/hastables etc to null after not being used anymore?
Q4:when does GC.Collect() collects the garbage (resources)?

I am using GC.Collect in a thread running every 1 second and I've also set the variables to null after their no longer used but it seems just like more and more memory is used to idk o.O

If you can't give any answer it's good anyway
ryuchetval is offline  
Old 10/16/2010, 04:48   #2
 
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
Addressing the title: you can't have a 'memory leak' in C# unless you're calling C functions. Using the FCL you won't get any.

ValueTypes (ints, doubles, shorts, etc) don't use heap memory, they use stack memory. Stack memory is cleared after the function exits.

Classes such as arrays/hashtables are managed and consume memory. You can't explicitly delete them from memory; the GC will handle it when it goes out of scope. C# is garbage collected, you don't need to worry about memory management.

It's not of any use really as the object will be cleaned up when it goes out of scope anyways.

The GC compacts and frees resources periodically when it needs to. If your program isn't tight for memory it won't bother running too frequently (as it does have to interrupt your program). You shouldn't call it explicitly as the algorithm it has on its own will be the most efficient 95% of the time.

If you really want to learn I'll give a better explanation of why later.
_tao4229_ is offline  
Thanks
1 User
Old 10/16/2010, 07:55   #3
 
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
Ye I wanna learn badly cuz sometimes my source consumes 300 mb in 3-4 hours...and sometimes in 7-8 hours o.O...
ryuchetval is offline  
Old 10/20/2010, 00:48   #4
 
andyd123's Avatar
 
elite*gold: 20
Join Date: Apr 2006
Posts: 1,341
Received Thanks: 886
One of the most likely problems you have is either, as tao said, relating to the size of your hashtables and dictionary entries, so forth.

Use ANTS, or something like it, and you can find out what variables are taking up the most space, and for the most part can help you defeat them. Afaik the GC will -not- dispose of any object inside of a hashtable or collection unless the collection is disposed of.

tl;dr: Collections are probably your problem.
andyd123 is offline  
Old 10/20/2010, 05:15   #5
 
elite*gold: 0
Join Date: Sep 2010
Posts: 15
Received Thanks: 10
i have one
KC Royals is offline  
Old 10/20/2010, 08:14   #6
 
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
can you tell me what does ANTS mean?
ryuchetval is offline  
Old 10/20/2010, 12:19   #7
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
Hybrids video tutorial explain alot about memory use of variables
I think u should watch it
Fish* is offline  
Old 10/20/2010, 22:33   #8
 
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
well i believe collections are my problem...not sure tho...also I've noticed that if i put .clear instead of = null; to a collection after I don't need it anymore it doesn't free any memory at all...
ryuchetval is offline  
Old 10/20/2010, 22:52   #9
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
Well hybrids videos are awesome, they explain alot and what could cause problems and so and he tells alot about collections wich I really like.
Its awesome.
Also he explains why u get alot random null exceptions.
Wich is awesome

I just <3 His videos.
Fish* is offline  
Old 10/20/2010, 23:24   #10
 
andyd123's Avatar
 
elite*gold: 20
Join Date: Apr 2006
Posts: 1,341
Received Thanks: 886
Quote:
Originally Posted by ryuchetval View Post
well i believe collections are my problem...not sure tho...also I've noticed that if i put .clear instead of = null; to a collection after I don't need it anymore it doesn't free any memory at all...
If you clear a collection, it removes the objects from the collection, allowing the GC to dispose of them provided they are not referenced anywhere else.
Clearing the collection will not instantly free any memory. The GC will only attempt to free memory when it needs to, as Saint said. Think of it like....investing in stock? If you put $100 into stock, and you see it's worth 1000 now, that doesn't mean for sure that you will take that money out then, right? If you see it raise or fall more, you may want to quickly though. If the GC doesn't see a -need- to free memory, it wont, and it shouldn't, because it has to interrupt the program to do so(making it slower..).

Connections are probably not your problem, it's possible, but I see it as far less likely.
andyd123 is offline  
Old 10/21/2010, 08:15   #11
 
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
Quote:
Originally Posted by Fish* View Post
Well hybrids videos are awesome, they explain alot and what could cause problems and so and he tells alot about collections wich I really like.
Its awesome.
Also he explains why u get alot random null exceptions.
Wich is awesome

I just <3 His videos.
could you point me to this video? I couldn't search for his name/thread

Quote:
Originally Posted by andyd123 View Post
If you clear a collection, it removes the objects from the collection, allowing the GC to dispose of them provided they are not referenced anywhere else.
Clearing the collection will not instantly free any memory. The GC will only attempt to free memory when it needs to, as Saint said. Think of it like....investing in stock? If you put $100 into stock, and you see it's worth 1000 now, that doesn't mean for sure that you will take that money out then, right? If you see it raise or fall more, you may want to quickly though. If the GC doesn't see a -need- to free memory, it wont, and it shouldn't, because it has to interrupt the program to do so(making it slower..).

Connections are probably not your problem, it's possible, but I see it as far less likely.
Well...when the ram usage reaches 1/1.2 GB it still doesn't go down at all...furthermore it will crash after this amount of RAM at any time...as it happens all the time
ryuchetval is offline  
Old 10/21/2010, 08:20   #12
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
Quote:
Originally Posted by ryuchetval View Post
could you point me to this video? I couldn't search for his name/thread
its stickied in the programmign section.
Arcо is offline  
Old 10/21/2010, 15:31   #13
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
Quote:
Originally Posted by ryuchetval View Post
could you point me to this video? I couldn't search for his name/thread
infamousnoone = hybrid.
Fish* is offline  
Old 10/21/2010, 22:30   #14
 
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
thanks for your help guys...hope i'll get it fixed
ryuchetval is offline  
Old 10/22/2010, 19:32   #15
 
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
1st...sorry for double post...
2nd...what's better for collections.... clear or null? (sry if it's in the hybrid's tuts...I didn't get to watch them)
ryuchetval is offline  
Reply


Similar Threads Similar Threads
ZSZC SRO-DB Bot Memory Leak?
06/13/2010 - SRO Private Server - 7 Replies
I'm using the .8 one since the .9 doesn't attack. But I'm just wondering, after say half an hour or so, the games gets extremely laggy. Does anyone have this issue as well and is it just due to a memory leak. Thanks!
5127 Memory Leak
06/08/2009 - Conquer Online 2 - 13 Replies
Has anyone found a solution to the memory leak problem that started after patch 5127? My clients has been experiencing a constant increase in the amount of RAM used by Conquer since patch 5127 have been installed. After looking in CO's official forum, I am pretty sure that it has not been cause by something from my side since many players have also having the same problem.
CO Partner Memory Leak?
06/18/2006 - Conquer Online 2 - 8 Replies
Does it happen to any one else; after 5-10 mins of lvling it just ignores the mobs and random runs around.
4302 patch memory leak on hex edited exe
04/04/2006 - Conquer Online 2 - 4 Replies
I just installed Patch 4302 and i get memory leak after i hex edited the Conquer.exe.. and ini mod doesnt seem to work for me.. any one any ideas?



All times are GMT +1. The time now is 01:06.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.