|
You last visited: Today at 01:05
Advertisement
Memory Leak?
Discussion on Memory Leak? within the CO2 Private Server forum part of the Conquer Online 2 category.
10/15/2010, 23:16
|
#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
|
|
|
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.
|
|
|
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...
|
|
|
10/20/2010, 00:48
|
#4
|
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.
|
|
|
10/20/2010, 05:15
|
#5
|
elite*gold: 0
Join Date: Sep 2010
Posts: 15
Received Thanks: 10
|
i have one
|
|
|
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?
|
|
|
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
|
|
|
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...
|
|
|
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.
|
|
|
10/20/2010, 23:24
|
#10
|
elite*gold: 20
Join Date: Apr 2006
Posts: 1,341
Received Thanks: 886
|
Quote:
Originally Posted by ryuchetval
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.
|
|
|
10/21/2010, 08:15
|
#11
|
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
|
Quote:
Originally Posted by Fish*
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
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
|
|
|
10/21/2010, 08:20
|
#12
|
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
|
Quote:
Originally Posted by ryuchetval
could you point me to this video? I couldn't search for his name/thread
|
its stickied in the programmign section.
|
|
|
10/21/2010, 15:31
|
#13
|
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
|
Quote:
Originally Posted by ryuchetval
could you point me to this video? I couldn't search for his name/thread
|
infamousnoone = hybrid.
|
|
|
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
|
|
|
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)
|
|
|
 |
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.
|
|