Re: java.net.SocketException: Insufficient buffer space

From: John C. Bollinger (jobollin_at_indiana.edu)
Date: 11/04/04


Date: Thu, 04 Nov 2004 13:03:22 -0500

I wrote:
> wasting memory. Unless you can determine the message size before
> allocating the buffer, you have an unavoidable space / speed tradeoff
> going on here.

Which is true as far as it goes, but upon further reflection I realize
that if the typical message is considerably smaller than the largest
possible message, and if there are a lot of messages, then the time to
allocate (and later GC) a large amount of unused buffer space many times
may trump the time it takes to copy bytes around in a scheme that uses a
smaller buffer by default and expands it as necessary for large
messages. Such an adaptation scheme could be incorporated into my
example code, but I'll spare you the details.

This all comes back around to the point that you need to _test_ to
determine where your performance problems are, and you need to _test_ to
determine whether any hand optimization you come up with actually
improves performance.

John Bollinger
jobollin@indiana.edu



Relevant Pages

  • Re: Reading text files using pointers?
    ... >> performance problems, I just want to try tweaking my routine in order ... or a block of characters. ... > chars) into a fixed buffer, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Reading text files using pointers?
    ... > performance problems, I just want to try tweaking my routine in order ... > Regarding the encoding of the file, I'm not really sure what it is, ... or a block of characters. ... chars) into a fixed buffer, ...
    (microsoft.public.dotnet.languages.csharp)
  • Changing output buffer size in dsp plugin
    ... I have created a plugin which is able both to increase and decrease the ... length of the buffer. ... therefore I need to find a way to realloc this output stream so it matches ... deallocating and allocating in the AllocateStreamingResources ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Buffer or Realloc?
    ... better to allocate memory and realloc it for the size of the what is ... between deciding to use a fixed size buffer or allocating memory ...
    (comp.lang.c)
  • Re: [PATCHSET] printk: implement printk_header() and merging printk, take #3
    ... result TF isn't available and thus res printout is ... require allocating yest another temp buf and separating out res printing ... needed to allocate the buffer elsewhere than stack. ...
    (Linux-Kernel)