Article View: borland.public.jbuilder.java.api
Article #985Re: OutOfMemoryError
From: John McGrath TeamB
Date: Tue, 02 Jul 2002 01:27
Date: Tue, 02 Jul 2002 01:27
33 lines
2042 bytes
2042 bytes
On Mon, 01 Jul 2002 17:40:45 -0400, Alan Shiers wrote:
> I created a client/server project. The server-side app
> allows the uploading of files from the client app. Today
> I tried to upload a rather large zipped file (60Mb) and
> this caused the JVM to display an OutOfMemoryError message
> on the console. Needless to say the file never did get
> uploaded.
>
> Is there a restriction as to how much data the JVM will
> allow.
Yes, there are always limits. The constraint may be the size of memory
or the size of the disk, but there is always a limit and you should be
aware of what the limits are.
> Aside from reducing the size of the file is there something
> else I can do to prevent the error from happening in the
> future?
It sounds like you are reading the entire file into memory, which is
not a good thing to do. Instead, process it in (relatively small)
chunks, such as 64K bytes or so. Then the amount of memory required
will be a fixed amount rather than the size of the file.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<MPG.178acb912dba8f7998b79d@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.gamma.ru!Gamma.RU!newspeer.clara.net!news.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3D20CC5D.B70473C9@hfx.eastlink.ca>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,28eab50e784856ac X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2002-07-01 18:40:13 PST From: John McGrath [TeamB] <ng-b@JPMcGrath.net> Newsgroups: borland.public.jbuilder.java.api Subject: Re: OutOfMemoryError Date: Mon, 1 Jul 2002 21:27:39 -0400 Message-ID: <MPG.178acb912dba8f7998b79d@newsgroups.borland.com> References: <3D20CC5D.B70473C9@hfx.eastlink.ca> X-Newsreader: MicroPlanet Gravity v2.60 NNTP-Posting-Host: 209.92.40.60 X-Trace: dnews 1025573257 209.92.40.60 (1 Jul 2002 18:27:37 -0700) Lines: 33 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.gamma.ru!Gamma.RU!newspeer.clara.net!news.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews