Any possibility of creating a low memory footprint CLI build?

neminem

New member
I'm just curious. The context: I'm primarily responsible for the maintenance of testudinata, Binary and whositbot, and am going on vacation for 3 weeks, such that I won't have the ability to toggle my home router if Verizon messes up our connection, which happens with annoying frequency. Luckily (I thought), my other half has a VPS, so I figured I'd just host the bots (as well as my own bot to burn my turns while I'm gone) there.

One problem: her VPS is a bare-bones machine with only 256MB of ram. I'd forgotten to check that, and hadn't considered that each Mafia instance eats 100-150MB by itself. So I'm just curious, to any Mafia developers or other people who really know their way around Java and the Mafia source, whether there might be any tricks I could use to significantly cut down on memory usage, given that in this context, it will always be run in CLI? I'm fine recompiling and with some amount of source-fiddling, but I'm not a Java expert.

It just seems weird that it would really need that much ram (especially running as CLI), when it's really just keeping track of a bunch of counters, making web requests, and printing stuff to console output. Ok, fine, and parsing and running scripts, but still.

If there isn't any moderately easy way, I'll either have to bug her to add more RAM to her VPS for a month, or just keep running it from home and hope Verizon doesn't crap out while I'm gone. >.>

Thanks!
 

neminem

New member
Can't you just tell mafia how much RAM it's allowed to use since it's a Java app?
I did try that, but unless there's some other less intrusive way than the way I found (Xmx64M), it doesn't work. Or I should say, it worked slightly better, in that instead of causing some other process to run out of memory and die, at least it was polite enough to kill itself (with an out of memory exception). But I did get an out of memory exception midway through logging the second bot in, that way. Hence, my wondering whether anyone had a guess what might be consuming so much ram, and whether it would be possible to excise any of it if it related to sections of Mafia a buffbot had no particular need of. (I haven't written anything in Java in forever, but I'm reasonably confident a Hello World, for instance, would still take up much less ram than that, even factoring in running the JVM?)
 

Theraze

Active member
java -Xms32m -Xmx64m -Duser.dir="Full KoLmafia Folder location" -jar "Full KoLmafia jar location"
This worked for me running 2 characters. Slow as all get out, but it did log in. Also, two more things... you can use the CLI line to skip creating a GUI if your buffbot will run headless - not sure if that actually works. And you can apparently tune the Java GC.
Hola gave some info on that when I asked 3 years ago.
http://kolmafia.us/showthread.php?6167-Command-line-options
 

neminem

New member
Heh. I tried exactly that set of memory specifications on my actual physical machine (which does have plenty of ram, at least as far as this goes). ps aux tells me that each instance is limiting itself to around 80 megs of physical memory, but only because it's now using about 225 megs total (including swap). This VPS also has no swap. :(

But yes, you can definitely skip creating a GUI, I'm doing that already. At least, I'm running it with that flag, which results in it printing everything to console - unknown whether it actually loads less into memory as a result, sort of part of what I was wondering.
 
Top