Skip to content
Advertisement

AnyLogic memory error: how to know how much the threshold is exceeded?

I have a lot of road traffic and markup elements, charts, nodes and arcs within my Main agent. When running the simulation it throws the following error:

Description: The code of method _createPersistentElementsBP4_xjal() is exceeding the 65535 bytes limit.

I read this article: https://noorjax.com/2018/10/17/your-agent-is-too-big-memory-problem/

However, I would like to know how much have I exceeded the limit. Is there any way of getting this information? Because if it is not that far from the threshold, I can make some modifications to drop below that threshold. Otherwise it is painful to create so many new agents, etc.

Advertisement

Answer

This is a Java Virtual Machine (JVM) restriction on the Java bytecode size for the method body (i.e., the compiled code size) as I understand it (e.g., see Baeldung’s description which links to the relevant JVM specification details). Thus, even though you can see the generated Java source code for the offending method, it isn’t actually the length of that that is the limitation (though obviously the length of the source code correlates to some degree with the size of the compiled bytecode).

[As such, I’m surprised if Felipe’s idea of reducing variable name lengths makes any difference since they’re not stored explicitly like that in the bytecode…]

So, no, you can’t tell how much you’ve exceeded it by (unless I guess you actually interrogate compiled class files and know exactly what you’re doing). Even though it is AnyLogic’s code generation that is ‘causing’ the problem, any such situation will normally always be something that you could re-architect better (as with Felipe’s example) from an object-oriented (or data structuring) design perspective in the model.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement