I propose that the OSResourceMonitor abomination is removed. It sits in front of our OSMemory.malloc() calls to check there is enough system memory.
First, it is going to make all our regular mallocs (from Java) slow by making these extra JNI + system calls. At least it should be written to kick-in when an OOM exception is thrown, not on every call! Second, it is there IIRC to attempt to solve the problem of NIO direct byte buffers. I'm not convinced it will do a good job of that -- invoking System.gc() in a loop is hopeful at best, and again taxing every call to malloc up from for this is unreasonable. The current situation is a hack to work around the lack of public API to free a direct byte buffer. There is a far better hack available, and that is for apps to cast down and call free explicitly, i.e. ((DirectByteBuffer)myBuffer).free() Regards, Tim