The only suggestion I have is to increase memory allocation;  In "real life"
you are likely to get periods when garbage collection can be performed while
the server waits for a message.


At 07:50 PM 8/30/00 +0800, you wrote:
>thanks for the detailed response. is there any way to solve this problem?
>this would be a major bottleneck for heavy network server apps where packets
>has to be read into buffer and released when done processing.
>
>tks,
>peter
>
>----- Original Message -----
>From: "Bill Hackmann" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, August 30, 2000 7:24 PM
>Subject: Re: slow memory allocation problem
>
>
>> You have discovered one of the fundamental differences between Java and
>C++;
>>
>> In C++, when you allocate and then delete a block of memory, it is
>immediately
>> combined with adjacent free blocks, and the free memory chain can be
>scanned
>> quite quickly;
>>
>> In your case, you simply dereference an array, which will not be garbage
>> collected until
>> 1) Some free time is available (never true since you thread will have
>higher
>> priority as long as memory is available)
>> 2) Your allocation request cannot be satisfied
>>
>> Eventually, you are probably running garbage collection every couple of
>loops;
>> GC can be slow, and is very implementation dependent;
>>
>> If you want the slower sequence at the start of your run, run your Java
>program
>> loop backwards, from NUM_MAX_BYTES  to 1;
>>
>> This is an inherent result of using Java's chosen memory model.
>>
>> If you were only interested in reducing the variance, if you waited a
>short
>> will after each allocation (Thread.sleep(1)) you might find the variance
>> reduced, but Java would take a minimum of NUM_MAX_BYTES milliseconds to
>run, 5
>> minutes in your example.  Also, I am not sure at all how Thread.sleep(n)
>works
>> on a platform where the clock resolution is low, as on most Windows
>platforms.
>>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to