DataHandler OutOfMemory problem

From: Ian Jones <>
Date: Wed, 15 Dec 2004 11:15:29 -0000

Hi all,
I'm using a DataHandler to download a file from our server to a local
PC. This is working fine until the files get relatively large, e.g. I'm
currently attempting to transfer a zipped up file that is about 30Mb,
and then I the client reports an OutOfMemory error.
Here's a code snippet of the point in the code where the error is
                          "Requesting file");
                        // ask for the file here
                        DataHandler dh = client.getFile(filePath);
              "Got data handler");
I get the first log message - "Requesting file" - and then the error. So
it is the retrieval of the DataHandler from the server, by calling
client.getFile() above, that is causing the error. The getFile() method
on the server simply does this:
    public DataHandler getFile(String filename) throws RemoteException {
        return new DataHandler(new FileDataSource(new File(filename)));
I've increased the heap size of the java process running the client and
this stops the problem occurring. Is this the only way to stop this
happening? Or could I be doing something incorrectly to cause this
problem? I need to be able to deal with transferring files up to about
Any help will be greatly appreciated.
Ian Jones
Senior Analyst Developer
Piper Group plc
Tel: + 44 (0) 1454 284900
Fax: + 44 (0) 1454 284950 <>
Information contained in this e-mail is intended for the use of the
addressee only, and is confidential and may be the subject of legal
professional privilege. Any dissemination, distribution, copying or use
of this communication without permission of the addressee is strictly
prohibited. The views expressed in this communication may not
necessarily be the views held by Piper Group plc.