Re: garbage collection in bgt
I think I've narrowed it down to the class that's causing it, unfortunately, its the most frequently used object in the game. I can't figure out how it could cause a circular reference though.
The entity class represents a game object, and components define the object's attributes. And EntityManager class associates entities with components. I'm using the entity system paradigm if anyone's familiar with it.
// this is the code causing the garbage
ComponentType[] ids = {COMPONENT_PLAYER_CONTROLLED, COMPONENT_POSITION, COMPONENT_VELOCITY}; // ComponentType is just an enum
Entity[] movablePlayerEntities = entityManager.getEntitiesWith(ids);
// these are the members of the entity class
class Entity {
private EntityManager@ mgr; // i can't find any references from the EntityManager class to Entity objects
private int id = -1;
// default constructor
Entity() {
id = -1;
@mgr = null;
}
p>
Entity(EntityManager@ m, int entityId) {
assert(m is null == false);
@mgr = @m;
id = entityId;
}
// this is the method in Entity Manager that is called
// the entity manager does not store Entity objects. It only works with integer ids
Entity[] getEntitiesWith(ComponentType[] componentIds) {
assert(componentIds.length() > 0);
Entity[] result;
for (int entityId = 0; entityId < entities.length(); entityId++) {
if (entityHasComponents(entityId, componentIds))
result.insert_last(Entity(this, entityId));
}
return result;
}
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector