[jcifs] How to make jCIFS 1.3.14 more stable
Michael B Allen
ioplex at gmail.com
Fri Jun 4 15:44:45 MDT 2010
On Thu, Jun 3, 2010 at 4:49 PM, Del Merritt <del at alum.mit.edu> wrote:
> Mike wrote:
> I didn't try the second patch mentioned below.
>
> While on the subject of patches: the getBuffers() method in
> jcifs.smb.BufferCache.java currently looks like this:
>
> static void getBuffers( SmbComTransaction req,
> SmbComTransactionResponse rsp ) {
> synchronized( cache ) {
> req.txn_buf = getBuffer();
> rsp.txn_buf = getBuffer();
> }
> }
>
> This causes performance issues on the BlackBerry platform. I believe this is
> caused by what to me appears to be excessive use of "synchronized" in that
> method. The getBuffer() method, which this calls, already is guarded by:
>
> synchronized( cache ) {...}
>
> So I don't believe it is required in getBuffers() as well, at least given the
> latter's current implementation.
The synchronized in getBuffers is required because both buffers must
be allocated together or not at all. Otherwise, Thread A could grab
one buffer, Thread B could grab a second buffer at which point, if
there were no more buffers, you would have a deadlock.
Also I somewhat doubt the "excessive use of synchronized" theory. You
should be able to call synchronized any number of times. If you're
seeing some kind of a problem with buffers I suspect it is simple
buffer exhaustion. Although on a small handheld device you should
probably *reduce* the number of buffers by setting
jcifs.smb.maxBuffers = 4 or so. Each buffer is 16K which is probably
quite a bit of memory for a phone. Besides, a phone is not going to be
doing a lot of concurrent requests so it doesn't need a lot of
buffers.
Mike
--
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
More information about the jCIFS
mailing list