Forum Discussion
MSGreg
13 years agoVisitor
TL;DR Try allocating the msg port right after allocating the roScreen and outside the loop.
This may help in keeping memory from being fragmented.
Here is the reference guide on Garbage Collection. Objects are de-allocated when they are assigned invalid; more precisely: when their reference count goes to zero. RunGarbageCollection() is only necessary to remove circular references. I also thought about setting to invalid (as TheEndless suggested) but wasn't sure in the original statement if the de-allocation occurred before the allocation or vice versa. Setting to invalid certainly removes the ambiguity.
In my experience, the order of allocations / de-allocations make a difference. I presume because of memory fragmentation. Take care to de-allocate everything you've allocated since the bitmap. In the code, you are allocating a msgport after the bitmap. And it's being allocated/de-allocated every loop.
This may help in keeping memory from being fragmented.
Here is the reference guide on Garbage Collection. Objects are de-allocated when they are assigned invalid; more precisely: when their reference count goes to zero. RunGarbageCollection() is only necessary to remove circular references. I also thought about setting to invalid (as TheEndless suggested) but wasn't sure in the original statement if the de-allocation occurred before the allocation or vice versa. Setting to invalid certainly removes the ambiguity.
In my experience, the order of allocations / de-allocations make a difference. I presume because of memory fragmentation. Take care to de-allocate everything you've allocated since the bitmap. In the code, you are allocating a msgport after the bitmap. And it's being allocated/de-allocated every loop.