G
Gotisch
Hi,
we are currently writing an mostly singlethreaded (game)server
application in c#. But we are encountering problems with the Garbage
Collector: After a certain time but also apparently randomly the GC
starts working Alot and taking up to 60-70% of the cpu time, which
results in huge lags in responce time of the server.
The server uses (depending on the setting) around 350-800 MB of memory
( the servers we tested this on had from 1gb to 3gb of memory) most of
which is in gen2 heap. That itself is inevitably since its loads
spawners (object that will create mobiles or gameobjects over the time)
and gameobjects / mobiles into the world.
Now we think the problem might be comming from the gc having to move
through those when a GC occurs. ( Can you clear me up on this point?
afaik worst case the gc has to check all objects to see if they hold a
reference to objects on gen0, or am i misunderstanding this?)
Removing the long-living objects ofcourse stops this problem, but then
the server takes nearly no memory at all.
Another weird thing is, that our gen0 seems to be maxed out all the
time. This could come from the network part, which stores incomming
data into a packet that is enqueued and then processed by the mainloop
every 20 milliseconds(for every client). Inserting a GC.GetGeneration
debug output shows that from 50 packets around 5 make it to generation1
and 1 to generation2, could this be cause for the problem?
I doubt this though because the spikes don't occur at the same time a
gen2 collection occurs. The count of gen0 - gen1 - gen2 isnt that bad
either its approximatly 1000 - 500 - 1.
We though moving all the very long living objects that stay through the
whole applications lifetime to the large object heap could avoid those
making problems, but apparently you cant move small objects there
anyway?
Or it could be that gen0 / 1 are to fragmented. From a dump we get:
Gen0 is size 423592 with 71148 free - 16% fragmentation?
Gen1 is size 1134596 with 71160 free - 6% fragmentation?
Gen2 is size 530020272 with 6989736 free - 1.3% fragmentation?
Is it true that fragmentation above 10% is a nono in gen0 heap? if yes
how can we find out what is causing it?
What would really help me are some hints how to figure out what causes
the GC to use that much cpu time. At the moment we can only guess,
which isn't really bringing forth anything.
How should we start investigating what is causing this problem? I
assume there is no way to see what the garbage collector is doing when
he is taking that much cpu? if its marking objects for collection,
moving them or whatever?
We also tried to get dumps from the heap before and after a "spike" but
with about 8 million objects its hard to see any relation between
before and after a spike.
I would be greatfull for any tipps you could supply.
Thank you
we are currently writing an mostly singlethreaded (game)server
application in c#. But we are encountering problems with the Garbage
Collector: After a certain time but also apparently randomly the GC
starts working Alot and taking up to 60-70% of the cpu time, which
results in huge lags in responce time of the server.
The server uses (depending on the setting) around 350-800 MB of memory
( the servers we tested this on had from 1gb to 3gb of memory) most of
which is in gen2 heap. That itself is inevitably since its loads
spawners (object that will create mobiles or gameobjects over the time)
and gameobjects / mobiles into the world.
Now we think the problem might be comming from the gc having to move
through those when a GC occurs. ( Can you clear me up on this point?
afaik worst case the gc has to check all objects to see if they hold a
reference to objects on gen0, or am i misunderstanding this?)
Removing the long-living objects ofcourse stops this problem, but then
the server takes nearly no memory at all.
Another weird thing is, that our gen0 seems to be maxed out all the
time. This could come from the network part, which stores incomming
data into a packet that is enqueued and then processed by the mainloop
every 20 milliseconds(for every client). Inserting a GC.GetGeneration
debug output shows that from 50 packets around 5 make it to generation1
and 1 to generation2, could this be cause for the problem?
I doubt this though because the spikes don't occur at the same time a
gen2 collection occurs. The count of gen0 - gen1 - gen2 isnt that bad
either its approximatly 1000 - 500 - 1.
We though moving all the very long living objects that stay through the
whole applications lifetime to the large object heap could avoid those
making problems, but apparently you cant move small objects there
anyway?
Or it could be that gen0 / 1 are to fragmented. From a dump we get:
Gen0 is size 423592 with 71148 free - 16% fragmentation?
Gen1 is size 1134596 with 71160 free - 6% fragmentation?
Gen2 is size 530020272 with 6989736 free - 1.3% fragmentation?
Is it true that fragmentation above 10% is a nono in gen0 heap? if yes
how can we find out what is causing it?
What would really help me are some hints how to figure out what causes
the GC to use that much cpu time. At the moment we can only guess,
which isn't really bringing forth anything.
How should we start investigating what is causing this problem? I
assume there is no way to see what the garbage collector is doing when
he is taking that much cpu? if its marking objects for collection,
moving them or whatever?
We also tried to get dumps from the heap before and after a "spike" but
with about 8 million objects its hard to see any relation between
before and after a spike.
I would be greatfull for any tipps you could supply.
Thank you