Memory leaks?

Has anyone else experienced memory issues with some of the newest builds, as of the past month or so?

I've had trouble isolating exactly what is causing it, but in roughly 1/3 of my mafia sessions, the memory counter eventually fills up and indicates that mafia is maxing out its allocated memory, which causes combats to run extremely slowly. Manually forcing garbage collection doesn't help. Only closing the app and restarting fixes the issue.

I'm running under Vista with 1GB of RAM, but I've also had the same problem occur on an XP machine with 4GB of RAM.
 

halfvoid

Member
I've noticed this as well. Posted something about it in one of the threads when i asked if there was a cli command to automate the garbage collecting. I'm running XP with a gig of ram and mafia only allocates 65088kb of ram for itself.
 
I've noticed this as well. Posted something about it in one of the threads when i asked if there was a cli command to automate the garbage collecting. I'm running XP with a gig of ram and mafia only allocates 65088kb of ram for itself.

Yep, mafia allocates the same amount of RAM on my 1GB and 4GB machines.

When it maxes out its memory, garbage collection doesn't seem to help me - it only frees up a few hundred K and mafia continues to be unusable until I shut it down and restart it.
 

jasonharper

Developer
You say this only happens in 1/3 of your sessions... what's the pattern? Is there some script that you're only using in those particular sessions? Some item you use, or some location you visit?
 
Experiencing this issue right now: memory says 57779 KB / 650888 KB.

The application is very unresponsive - noticeable lag in both chat and CLI, despite the fact that I'm at ~1% CPU usage and have 2GB RAM free out of 4GB.

Pretty much forced to restart Mafia at this point.
 
You say this only happens in 1/3 of your sessions... what's the pattern? Is there some script that you're only using in those particular sessions? Some item you use, or some location you visit?

In this particular case, I am adventuring in the slime tube and calling an ASH script to visit the chamoix URL to remove slimy. That's pretty much it.

The exact command I'm executing is:
adventure 2 slime tube; call chamois

Where chamois is just: visit_url("clan_slimetube.php?action=chamois&pwd");
 
I think the common thread that jumps out at me is that each time I have encountered this problem, I've been using ASH scripts. On my recent BM run, adventuring manually in the relay browser never seemed to raise this issue.

I've seen some references to changing memory allocation strategy with respect to ASH script in the changelogs recently - perhaps it's related to that somehow?
 
Another clue: I just looked in my mafia directory and saw that mafia spit out a debug log right around the time the memory issues began. And now that I think back - I've seen a debug log like this after every instance of encountering this memory problem.

Too long to post the whole thing here, but it looks like this:

Code:
class java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
	at java.awt.EventQueue.invokeAndWait(Unknown Source)
	at javax.swing.SwingUtilities.invokeAndWait(Unknown Source) ...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
	at javax.swing.text.BoxView.getOffset(Unknown Source)
	at javax.swing.text.BoxView.childAllocation(Unknown Source)
	at javax.swing.text.CompositeView.getChildAllocation(Unknown Source)
	at javax.swing.text.BoxView.getChildAllocation(Unknown Source)
	at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.calculateViewPosition(Unknown Source)
	at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.layoutContainer(Unknown Source)...
class java.lang.ArrayIndexOutOfBoundsException: 0
java.lang.ArrayIndexOutOfBoundsException: 0
	at javax.swing.text.BoxView.getOffset(Unknown Source)
	at javax.swing.text.BoxView.childAllocation(Unknown Source)
	at javax.swing.text.CompositeView.getChildAllocation(Unknown Source)
	at javax.swing.text.BoxView.getChildAllocation(Unknown Source)
	at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.calculateViewPosition(Unknown Source)...
 

halfvoid

Member
I've had it happen while running scripts (i currently have smartstasis and BBE set and i've been using mostly a variation of my sandworm farmer script or ascend.ash and the MMG a couple times but never again), its happened while simply autoadventuring (primarily in the oasis and whereever the bounty hunt takes me), and a couple times transfering stuff between my inventory, clan, and store.

every time its the same situation. the collect garbage thing works automatically a few times as it gets closer to being completely at full memory and then its like it gives up if it gets too close to 65088k and either hangs or crashes.
 

tgetgel

Member
Adventuring in Haunted Bathroom - trying to get the demon name.

Restarted KolMafia - 13.5. Beginning memory usage 22777. Sitting doing nothing, the usage slowly increases a couple of KB every few seconds. When I change the focus to the browser (chrome) it jumped up a couple of hundred KB. It is now at 23285.

After 20 adventures, it finished at 38274. Doing 20 more adventures, it got up to a max of just over 45K. (No mood triggers.) It is now at 32174 doing nothing.

I guess the question is, what is the expected performance?
 
I guess the question is, what is the expected performance?

I'd like to ask the same thing.

Based on this thread (and figuring out it must refer to the bar in the upper right of Mafia's main window), I've been watching the usage.

It seems to constantly increase when you aren't doing anything, and increases faster if you press the garbage collection button while not doing anything. (Not too surprising, since that starts a process.)

But once you do something, like open the relay browser or gCLI, it drops fairly dramatically.
 

halfvoid

Member
I'd like to ask the same thing.

Based on this thread (and figuring out it must refer to the bar in the upper right of Mafia's main window), I've been watching the usage.

It seems to constantly increase when you aren't doing anything, and increases faster if you press the garbage collection button while not doing anything. (Not too surprising, since that starts a process.)

But once you do something, like open the relay browser or gCLI, it drops fairly dramatically.

seems to be the exact opposite for me. it starts to fill up whenever i do something, ie. the things i posted earlier. i usually flip over to the CLI to see whats actually going down with the script or auto adventures.
 

Heffed

Member
I used to like to run the gCLI in the right pane of the relay browser. That quickly borks now. Same with chat, although not as quickly as the gCLI.

If I use those from within KoLmafia I can stave off the effects for a bit longer, but mafia will eventually need Java to be completely closed in order to be even slightly usable.

I'd love to be able to go back to the previous method because it's much more convenient having everything in the relay browser instead of toggling back and forth between the relay browser and KoLmafia.
 

Catch-22

Active member
What version of Java Runtime Environment are you guys running?
Do you have more than one?

If you do, uninstall all of them and install the latest one from the Java website.
 

HippoKing

Member
I've noticed a couple of times, Mafia will eventually reach full memory usage (on the bar on the top right) and then lock up. This is generally after it has been running for maybe 10 hours, and has been used primarily for the chat tab.
 

Catch-22

Active member
Not sure if it's worth you guys trying jvmstat and keeping an eye on it while you're using Mafia. I think different users are experiencing different problems.

Try manually specifying a heapsize at runtime using the -Xmx switch.
Code:
java -jar -Xmx128m KoLmafia.jar

If there's a memory leak then 128mb should eventually fill up. If the 128mb never fills up then there could be a configuration issue within KoLmafia, or perhaps one of your scripts is extremely resource hungry.

The chat tab could be something to investigate, I don't use chat and typically do not have Mafia open for longer than a few hours. Perhaps the chat history is arbitrarily filling up memory. I know there were similar issues with a lot of early IRC clients that didn't flush their chat history after X amount of lines. KoLmafia may be suffering from a similar fate, I'm not sure how it handles chat backlog.
 
Last edited:
Top