1

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 BiMaps 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.

CPUFry
  • 566
  • 4
  • 18
  • 1
    Thank you for investigating and reporting this issue! I've created a potential fix for this problem in the develop branch of RinSim https://github.com/rinde/RinSim/tree/develop The unregistered collection is now cache with a maximum capacity. Let me know if this works for you! – rinde May 30 '19 at 02:40
  • @rinde We ended up writing our own communication architecture cause of the impending deadline, but I will test and let you know when I find the time :-). – CPUFry Jun 20 '19 at 09:05

0 Answers0