We are trying to implement a delegate MAS in RinSim. We use a CommModel
, CommUser
and CommDevice
to send messages from the pheromones to the ants (simulating "smelling" the pheromone). We register the pheromone (derived from CommUser
to the simulation if the pheromone is dropped, and unregister it if it evaporates. Though it appears that they are not removed from the list of comm devices in the CommModel
(part of RinSim). We profiled the code using a tool, with the following as a result
One instance of "com.github.rinde.rinsim.core.model.comm.CommModel" loaded by "sun.misc.Launcher$AppClassLoader @ 0x8169f378" occupies 691,677,816 (99.43%) bytes. The memory is accumulated in one instance of "com.github.rinde.rinsim.util.LinkedHashBiMap" loaded by "sun.misc.Launcher$AppClassLoader @ 0x8169f378".
It keeps growing over time (though we do unregister the pheromones in the simulation).
We think the LinkedHashBiMap
refers to the usersDevices or unregisteredUsersDevices BiMap
s in CommModel
.
Should we do something differently to unregister the comm devices? Or is this a possible memory leak in the framework?
Edit
After looking into this further, it does appear there is an issue in the CommModel
class: after unregistering the comm user, the user and its device are saved in a list of unregistered devices/users, so that if they are registered again in the future, they get allocated the same device. Though this list is never cleared so all the ants that are destroyed remain in memory. We now used reflection to clear the list though this is not a good solution.