Bug - Not A Bug Mafia hogs shared memory under Linux

Hello,

Running OpenJDK-7.2.6.1 under Linux/amd64. Since about a month ago Mafia began to allocate and never release a massive number of SysV shared-memory segments, pretty quickly exhausting the limit and preventing other programs depending on shm - for example anything Qt-based - from working properly. The problem is definitely related to Mafia, as I have used the same JRE on the system to launch several other Java applications and none of them do the same.

Here is an example log of shared-memory allocation over time, with Mafia doing nothing but displaying chat. Actually using Mafia considerably speeds up shared-memory allocation - I have just hit over 20,000 allocated segments in less than one hour.

09:15:32 just before starting Mafia
segments allocated 12
pages allocated 18080

09:18:08
segments allocated 53
pages allocated 26600

09:42:50
segments allocated 4106
pages allocated 465812

10:14:51
segments allocated 7846
pages allocated 1571403

10:44:03
segments allocated 10356
pages allocated 2434308

11:43:33
segments allocated 15444
pages allocated 4195937

13:38:56
segments allocated 32768
pages allocated 9855371

14:22:50
segments allocated 32768
pages allocated 9855248

16:26:22 immediately after quitting Mafia
segments allocated 15
pages allocated 21280


As usual, let me know if you need any more information.
 

xKiv

Active member
And are you sure they are from mafia, and not from browser?

(apparently, learning which *all* processes are connected to a SHM segment is not trivial: https://stackoverflow.com/questions...-attached-to-a-shared-memory-segment-in-linux )

Hmm.

https://stackoverflow.com/questions/1491519/any-concept-of-shared-memory-in-java
> In theory, as I understand it, memory-mapped files CAN actually be backed by a shared memory segment (they're just file handles, I think) but I'm not aware of a way to do so in Java without JNI.
(~~ Java NIO's FileChannel ... source-referenced within tmatesoft/.../FSFile and SVNFileUtil, and KoLmafia.SESSION_CHANNEL, and FileUtilities in copyFile)
(so I would guess that a, it depends on system details and java version and b, it happens whenever writing to session log)
 

Veracity

Developer
Staff member
I all he's doing is "displaying chat", there is no session log activity. There is, however, a chat log.
 

xKiv

Active member
But that doesn't use NIO ... unless that particular java (or java 7 in general?) decided to redirect IO to NIO?
 

Veracity

Developer
Staff member
He is using OpenJDK, whatever that is. I appreciate that you researched what uses NIO - but I was pointing out that the session log file handle should be idle if there is nothing but chat happening, as the OP claims.
 

lostcalpolydude

Developer
Staff member
Running OpenJDK-7.2.6.1 under Linux/amd64. Since about a month ago Mafia began to allocate and never release a massive number of SysV shared-memory segments, pretty quickly exhausting the limit and preventing other programs depending on shm - for example anything Qt-based - from working properly. The problem is definitely related to Mafia, as I have used the same JRE on the system to launch several other Java applications and none of them do the same.

Were you using the same JRE before this started happening? Just because other programs don't cause the issue doesn't necessarily mean it's an issue with mafia instead of the JRE.
 
And are you sure they are from mafia, and not from browser?
I am pretty sure about that. On one hand, today I started Mafia without activating the relay-browser mode (i.e. logged in, opened the chat window and left it at that) and shared-memory segments kept getting allocated, albeit at a slower rate. On the other, I can have the browser itself (Firefox 38) running for days at a time and the number of allocated shm segments doesn't budge.

He is using OpenJDK, whatever that is.
As the name might suggest, it is an Open Source implementation of Java Platform Standard Edition and, for the correct versions of course, the official reference implementation of Java SE 7. Technically speaking what I run is not OpenJDK itself but IcedTea - but that's pretty much what everyone running Linux these days is likely to use for Java by default.

Were you using the same JRE before this started happening?
As it happens, I think there WAS a JRE update around the time I first noticed the problem... I'll look into this.
 

heeheehee

Developer
Staff member
Mafia relay browser + firefox developer on linux for me causes everything to be laggy. Mafia relay browser + chromium on linux is smooth sailing. I'm mostly sure this isn't a Mafia issue so much as a FF issue.
 
Mafia relay browser + firefox developer on linux for me causes everything to be laggy. Mafia relay browser + chromium on linux is smooth sailing. I'm mostly sure this isn't a Mafia issue so much as a FF issue.
Not so in my case though, the same happened when I switched the browser to be launched when starting the relay-browser mode to Chromium 45. Not exactly surprising given what I reported in my last post, namely that the problem also occurred running Mafia standalone.

Anyway, turns out the problem lay with IcedTea after all. Having just upgraded it to 7.2.6.2, everything looks fine - the Java process running Mafia (with the relay-browser mode active) allocated 3 shared-memory segments at startup and has kept it that way ever since.
 
Top