Hello!
I’ve left my webplayer build hanging in my browser for a night, and in the morning I found and error
“Fatal error in gc
Too many heap sections”
Is there something I am possibly doing wrong with memory?
thanks for any tips.
Hello!
I’ve left my webplayer build hanging in my browser for a night, and in the morning I found and error
“Fatal error in gc
Too many heap sections”
Is there something I am possibly doing wrong with memory?
thanks for any tips.
A quick search indicates it’s probably a bug in Mono’s garbage collector. Probably nothing you can do but wait until Unity 3 and hope that a newer version of Mono fixes the problem.
Hi,
Are you allocating a lot (like hundreds of thousands+) of small arrays, or something similar?
It’s probably due to memory allocation within the update() function. I’d really avoid creating new objects within the once-per-frame functions.
Instead, keep a private member function to store the things you need to create between frames, and only create new ones when they are needed.
i have the same problem in this part
public var iUser = new DemoData[100];
class DemoData
{
var name : String;
var id : int;
var x : float;
var y : float;
var z : float;
var Rx : float;
var Ry : float;
var Rz : float;
var hasrigidbody : boolean;
var Vx : float;
var Vy: float;
var Vz: float;
var childeren : int;
var iChild = new ChildData[100];
}
Getting the same problem with the game “Milmo”
after playing an average time of 1 hour, then, after the message, the plugin stops workin…
T_T
Please look at the MilMo-Forum for this error. This here might be a not so good place.
As you can see the problem is already known.
We’ve just hit this on our project, and unfortunately it happens after just a few minutes of gameplay. I just hope UT release the new GC implementation in 3.5.
The same here. Is there a method to monitor/measure the heap memory?
If you have Pro, you can either use the Profiler or use the underlying C functions:
[System.Runtime.InteropServices.DLLImport("__Internal")]
static extern long mono_gc_get_used_size(); //Amount Used
[System.Runtime.InteropServices.DLLImport("__Internal")]
static extern long mono_gc_get_heap_size(); //Total Amount
These are Thread-Safe and tell you the Total Heap size, and how much is currently being used. I know on iOS the total heap doesn’t go down, which is a problem as a large allocation block can permanently increment total memory used, even if general memory usage is lower.
This is only for the Managed code, and no C++ or underlying Unity engine code will be factored into these totals. Not sure if there is also a call to measure how many individual objects are being used by the GC, but if I find one I’ll post it here.
Edit:
http://www.acm.ndsu.nodak.edu/hosted/longjoel/mono-2.4/docs/deploy/mono-api-gc.html
Nothing looks to expose a Total Object count that I can see.
Edit: As far as reviewing these values, you want to keep Total as close to Used as possible, and should generally see a very gradual increase in Used up until it reaches Total and then a Cleanup back to some base position. If Used doesn’t move at all you are at ideal conditions and are not creating any per frame garbage.
Thanks a lot! this solved my problem…
at first i had no idea how to fix it, but I took all the object generating and deletion I had in update and replaced it with only generating things when needed (when the user pressed space) and the program stopped crashing