🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7360

Re: JAVA IO & Memory

#7360
From: CLG
Date: Sun, 24 Jun 2001 18:01
87 lines
3709 bytes
I dont think that program will work anyway.  If buffered reader is not
filled, it will just sit there.  So if the last read does not fill the
buffer, then the program will be sitting there.  You could try to avoid that
by setting a timeout on the socket and doing a flush.  also for efficiency,
you could set the buffers in your buffered reader to the same size (or
larger) as your byte array.

as for memory, I dont see where your storing anything.  the most you should
store here would be the size of your input buffer.


--
Peace,


Carl L. Gilbert
lamont_gilbert @ rigidsoftware.com
http://www.rigidsoftware.com
ICQ 614395-currently stolen working to retrieve.

"Then said I, Wisdom [is] better than strength: nevertheless the poor man's
wisdom [is] despised, and his words are not heard." Ecclesiastes 9:16

"Shoo" <edwinshoo@supanet.com> wrote in message news:3b360b14_1@dnews...
> Hello~~~
>
> I have a question about JAVA IO & Memory
>
> I ran the code(as below) for transferring images.
> However, after three minutes, the program stopped and the system showed
the
> information as follows.
>
> /////////////////////////////////////////////////////////////////////////
> Out of Swap Space
> ALERT: rf [4916] - out of logical swap
> space during brk/sbrk - see swap(1M)
> /////////////////////////////////////////////////////////////////////////
>
> It looks like the program ran out of memory.
>
> How can I free the memory in order to execute the program longer???
>
> Or, is there any method in Java similar with "malloc" in c?
>
> Thanks your reply. ^^
>
>
>
>
>     try {
>
>                 ServerSocket server = new ServerSocket( 10000, 10 );
>                 Socket connection = server.accept();
>
>                 BufferedInputStream input
>                      = new
BufferedInputStream(connection.getInputStream());
>
>                 Socket client = new Socket("doom-atm", 20000);
>
>                  BufferedOutputStream outputClient1
>                      = new BufferedOutputStream(client.getOutputStream());
>
>
>
////////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////////////////
>
> I think the problem probably comes from creating the array or the method
> write
>
>
////////////////////////////////////////////////////////////////////////////
> ////////////////////////////////////////
>                 int c;
>                 byte [] a = new byte[4096];
>                 while((c = input.read(a, 0 , 4096)) != -1 )
>                 {
>                  outputClient1.write(a, 0 ,c);
>                 }
>          }// end try
>
////////////////////////////////////////////////////////////////////////////
> //////////////////////////////////////////
>
>
Technical Details
Message-ID: <3b362bee$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3b360b14_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,ff189f3c7609b34f
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-24 11:10:10 PST
From: "CLG" <lamont_gilbert @ rigidsoftware.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3b360b14_1@dnews>
Subject: Re: JAVA IO & Memory
Date: Sun, 24 Jun 2001 14:01:19 -0400
Lines: 89
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 24.181.226.14
Message-ID: <3b362bee$1_2@dnews>
X-Trace: dnews 993405934 24.181.226.14 (24 Jun 2001 11:05:34 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews