And then, I looked at the debug. The issue is that the PS3MS code is asking for free memory, finding that it can't fulfill the transcode buffer request and cribs. Linux doesn't like to leave much RAM free, because the philosophy is to use free RAM for pagecache. We should make the check for total free (free+cache+buffers-unevictable-mlocked-dirty) not just free, and that too only after a malloc() has failed (which won't happen on my system, unless PS3MS wants to malloc more than 24GB). I think the code is doing it the other way around. Its checking for free (and only free) first and halving it if it can accommodate half, cribbing if not. And then doing the malloc.
I think the right sequence should be:
- Code: Select all
malloc(bufsize); // equivalent like ByteBuffer.allocate() I guess, whatever the code is doing now
total_free = free+cache+buffers-unevictable-mlocked-dirty (gotten from /proc/meminfo)
if (bufsize/2 < total_free)