You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Tim Ellison <t....@gmail.com> on 2009/10/01 10:55:35 UTC
[classlib] OSResourceMonitor must go
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
Re: [classlib] OSResourceMonitor must go
Posted by Alexey Petrenko <al...@gmail.com>.
:)
2009/10/1 Tim Ellison <t....@gmail.com>:
> On 01/Oct/2009 11:00, Alexey Petrenko wrote:
>> +1 from me as well.
>>
>> Actually I was against this patch from the very beginning since it's useless.
>> Here is the original JIRA issue:
>> http://issues.apache.org/jira/browse/HARMONY-3148
>
> Thanks Alexey. It has gone now -- so we are all happy again :-)
>
> Regards,
> Tim
>
>
>> 2009/10/1 Tim Ellison <t....@gmail.com>:
>>> 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
>>>
>>
>
Re: [classlib] OSResourceMonitor must go
Posted by Tim Ellison <t....@gmail.com>.
On 01/Oct/2009 11:00, Alexey Petrenko wrote:
> +1 from me as well.
>
> Actually I was against this patch from the very beginning since it's useless.
> Here is the original JIRA issue:
> http://issues.apache.org/jira/browse/HARMONY-3148
Thanks Alexey. It has gone now -- so we are all happy again :-)
Regards,
Tim
> 2009/10/1 Tim Ellison <t....@gmail.com>:
>> 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
>>
>
Re: [classlib] OSResourceMonitor must go
Posted by Alexey Petrenko <al...@gmail.com>.
+1 from me as well.
Actually I was against this patch from the very beginning since it's useless.
Here is the original JIRA issue:
http://issues.apache.org/jira/browse/HARMONY-3148
Alexey
2009/10/1 Tim Ellison <t....@gmail.com>:
> 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
>
Re: [classlib] OSResourceMonitor must go
Posted by Tim Ellison <t....@gmail.com>.
On 01/Oct/2009 09:55, Tim Ellison wrote:
> 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()
I should fix a typo here for the record... the cast is to a
_DirectBuffer_, like this:
import java.nio.ByteBuffer;
import org.apache.harmony.nio.internal.DirectBuffer;
public class FreeBuffer {
public static void main(String[] args) {
ByteBuffer myBuffer = ByteBuffer.allocateDirect(1024);
// do stuff
((DirectBuffer) myBuffer).free();
}
}
Regards,
Tim
Re: [classlib] OSResourceMonitor must go
Posted by Tim Ellison <t....@gmail.com>.
On 01/Oct/2009 10:04, Mark Hindess wrote:
> Harsh but fair. I'm +1 for removing it. It is a shame there isn't a public
> API but this problem should be handled by applications.
I'm going to take it out pronto. I realize it doesn't give people long
to object, but even if the consensus is that we have a problem to solve,
it won't be solved like this!
Regards,
Tim
> In message <4A...@gmail.com>, Tim Ellison writes:
>> 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
>>
>
>
>
Re: [classlib] OSResourceMonitor must go
Posted by Oliver Deakin <ol...@googlemail.com>.
Yep, +1 from me as well - this code is too hacky and costly for each malloc.
Regards,
Oliver
Mark Hindess wrote:
> Harsh but fair. I'm +1 for removing it. It is a shame there isn't a public
> API but this problem should be handled by applications.
> -Mark.
>
> In message <4A...@gmail.com>, Tim Ellison writes:
>
>> 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
>>
>>
>
>
>
>
--
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
Re: [classlib] OSResourceMonitor must go
Posted by Mark Hindess <ma...@googlemail.com>.
Harsh but fair. I'm +1 for removing it. It is a shame there isn't a public
API but this problem should be handled by applications.
-Mark.
In message <4A...@gmail.com>, Tim Ellison writes:
>
> 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
>