- adding an object (entity) to the space?
- collisions occur in the space ?
- calling UpdateBoundingBox ?
Garbage generated during add & collisions
Garbage generated during add & collisions
Hi, is it normal for a few kilobytes of heap memory to be allocated when:
Re: Garbage generated during add & collisions
Adding an object to the space could force expansion of various lists or data structures. The majority of the allocated space is not garbage; any garbage is just caused by old arrays that were thrown out after a resizing.adding an object (entity) to the space?
If the collision pairs exceed the pooled set of pairs, more will be created. When they are returned, the pool lists may need a resize, which can cause a little garbage. You can pre-pool however many you want by setting the capacities on relevant NarrowPhaseHelper.Factories.collisions occur in the space ?
UpdateBoundingBox should not cause garbage nor allocate on the heap. It is called every frame by every entity.calling UpdateBoundingBox ?
The important thing to note in the first two cases is that most allocated heap data is necessary, not garbage, and will not be subject to garbage collections. The actual garbage caused by simulation expansion is small, basically one-time, and can be handled up front in most cases.
If you encounter a scenario with excessive or anomalous garbage, I can take a closer look. CLR profiling results or a reproduction case would be helpful in diagnosing possible problems.
Re: Garbage generated during add & collisions
thanks, that makes sense. based on your explanation, the allocated memory I'm seeing during profiling seems normal (a test case where several hundred objects are added with a few hundred collisions)