i just tried it on NT 4.0.
i get the same results.

my next step is to download the inprise/linux version
from sun and see what that does.
i bet i have similar trouble.

can anyone else verify this problem with the provided code?
i would like to see results from the 1.8 jdk..

--michael


At 07:53 PM 1/5/00 -0200, Edson Carlos Ericksson Richter wrote:
>I'm sorry: cpu usage is not 100% because Java:
>53% java, 47% Apache Server...
>
>Actual report:
>
>86000 loops, 7128K ram + 5072K virt, rt.free()=2097144
>
>Edson Richter
>
>----------
>From:   Michael E. Moores
>Sent:   quarta-feira, 5 de janeiro de 2000 17:40
>To:     Edson Carlos Ericksson Richter
>Cc:     [EMAIL PROTECTED]
>Subject:        RE: heap space and performance
>
>so you can also see the heap get used up
>with the win32 JDK?
>i don't see how the blackdown JDK can be used
>for programs that persist for long periods.
>
>
>i tried several versions of that code.
>i agree you will always get a performance
>benefit by NOT calling object contructors inside of a long running loop.
>but my reason for doing it is to test out the
>jvm garbage collection and determine if the JDK is
>usable in a real application.
>
>i think the jvm/jdk has a big leak with one or more of the
>classes used.  i was having the same problem with HttpServlet..
>i cannot build a website with servlets and have it run
>longer than about 40,000 requests; using a servlet
>that DOES NOTHING BUT PRINT HELLO!
>i placed the main code in work() to make it obvious that
>the objects fall out of scope.
>
>
>here is the latest version, with construction IN THE LOOP!
>it runs out of heap after about 45,000 iterations,
>on linux 2.2, blackdown 1.2 (glibc 1.2.1)
>
>????who can show me this running a million iterations?????
>
>
>public class newtest extends Thread {
>      URLConnection yc;
>      Runtime rt = Runtime.getRuntime();
>      String inputLine;
>      int thflag;
>      public static void main(String[] args) throws Exception {
>          new newtest( args );
>      }
>      public newtest( String [] args ) {
>          int arg;
>          thflag = 0;
>          arg = Integer.parseInt( args[ 0 ] );
>          this.start( );
>          for( int i = 0; i < arg; i ++ ) {
>              work( i );
>          }
>          thflag = 1;
>      }
>      private void work( int i ) {
>      try {
>          if( i % 100 == 0 ) {
>              System.out.println( i + ":  " + rt.totalMemory( ) + " 
> bytes\n" );
>          }
>          URL yahoo = new URL( "http://127.0.0.1/" );
>          yc = yahoo.openConnection( );
>          BufferedReader in = new BufferedReader(new
>InputStreamReader(yc.getInputStream()));
>          while((inputLine = in.readLine()) != null) {
>               //System.out.println(inputLine);
>          }
>          in.close();
>          in = null;
>          yahoo = null;
>      } catch( IOException e ){ System.out.println("IO EXC\n"); thflag = 0;}
>      }
>      public void run( ) {
>          while(thflag == 0 ) {
>              try {
>                  this.sleep( 5000 ); // Encourage Garbage Colection every 5
>seconds
>                  rt.gc( );
>              } catch( Exception e ) {}
>          }
>      }
>}
>
>
>
>
>At 05:16 PM 1/5/00 -0200, you wrote:
> >Well, I've read your considerations, and make sense.
> >
> >But, I've tested this at work: using jdk1.2.2 final from Sun for NT (is at
> >my hands here).
> >And memory consumption does goes up with the code that I've writed...
> >
> >I'll try the code in a Linux box at this night, and make new
> >considerations. Really, using new() you will make an new allocation too.
> >Reading my old notes I've noted that using a class scope variable the code
> >run fastest (I've get this tip from Sun Dev. Conn.).
> >
> >Something that you can do to "inform" to Garbage Coll that a variable is
> >no more in use is putting Null value in the variable after their use.
> >
> >Try this, and report-me if you have success.
> >
> >No problems in contact-me directly.
> >
> >About e-commerce, values, and so on, I'm developing a healt care app, and
> >I know what about it. But Java (especially JSP and Servlets) is more
> >stable (I can't guarantee Linux version) than Visual Basic (by example)
> >and anyone take less errors coding in Java than C.
> >
> >[]s
> >
> >Edson Richter
> >
> >
> >----------
> >From:   Michael E. Moores
> >Sent:   quarta-feira, 5 de janeiro de 2000 16:55
> >To:     [EMAIL PROTECTED]
> >Subject:        RE: heap space and performance
> >
> >(edson, i should have CCd you..)
> >
> >
> >Edson (& java-linx),
> >
> >this code below runs out of heap space even faster than
> >my original program.  sorry the code probably does not
> >look good after being pasted into this email..
> >but the basic -->test<-- is to write some code which
> >will 1) actually do something and 2) will run -->FOREVER<--
> >(well... 6 months would be acceptable)
> >
> >i want to know that i can use the blackdown implementation
> >for serving a medium volume ecommerce site which is responsible
> >for millions of dollars of revenue.
> >so far, not so good.  but i am not a senior java developer,
> >so some inputs would be very much appreciated!
> >
> >i can bascially make any code run out of heap (latest build of 1.2)
> >even if i use this in a loop and then fall out of scope:
> >Integer[] int_a = new Integer[100000];
> >
> >in the code, you took a reference declaration and moved it
> >into class scope. i don't see how this does anything.
> >we are still calling new() in each iteration, and the garbage
> >collector SHOULD eventually free up the space.
> >the 5 second thread does not do anything more than making gc run a bit more
> >often; memory just goes up and after 40000 iterations blackdown jdk
> >dies hard.
> >moving declarations into class scope is not a rule we should use
> >unless that variable is shared amongst many methods and/or
> >must persist across method calls.
> >why does it matter if i repeat the use of new()?????????
> >i am not allocating the whole heap before the gc runs!!!!!!!!!
> >
> >
> >Edson wrote:
> >  >Heap consumption and performance are real problems in Java.
> >  >But some great pratices in coding solve (or amenizes) the problem:
> >  >
> >  >1) Don't repeat declaration of common used variables:
> >  >
> >  >2) Create a thread in your main class taking a "forced garbage 
> collection".
> >  >
> >  >See the following program, that I've reorganized to avoid duplicated
> >declarations, and should work forever:
> >
> >import java.io.*;
> >import java.net.*;
> >
> >public class newtest extends Thread {
> >         URL yahoo;
> >         URLConnection yc;
> >         Runtime rt = Runtime.getRuntime();
> >         BufferedReader in;
> >         String inputLine;
> >      int thflag;
> >         public static void main(String[] args) throws Exception {
> >                 new newtest( args );
> >         }
> >
> >         public newtest( String [] args ) {
> >                 int arg;
> >                  thflag = 0;
> >
> >                 arg = Integer.parseInt( args[ 0 ] );
> >                 this.start( );
> >
> >                 for( int i = 0; i < arg; i ++ ) {
> >                         work( i );
> >                 }
> >                  thflag = 1;
> >         }
> >
> >      private void work( int i ) {
> >                 try {
> >                         if( i % 100 == 0 ) {
> >                 System.out.println( i + ":  " + rt.totalMemory( ) + "
> > bytes\n"            );
> >                         }
> >
> >                         // the declarations was transferred to class
> > scope, avoiding wasted
> >memory allocation
> >                         yahoo = new URL( "http://127.0.0.1/" );
> >                         yc = yahoo.openConnection( );
> >                         in = new BufferedReader( new InputStreamReader(
> > yc.getInputStream( ) ) );
> >
> >                         while( ( inputLine = in.readLine( ) ) != null ) {
> >                                 //System.out.println(inputLine); don't
> > care about the output..
> >                         }
> >
> >                         in.close( );
> >                 } catch( IOException e ){
> >                 }
> >         }
> >
> >         public void run( ) {
> >                 while(thflag == 0 ) {
> >                         try {
> >                                 this.sleep( 5000 ); // Make a forced
> > Garbage Colection every 5 seconds
> >                                 rt.gc( );
> >                         } catch( Exception e ) {
> >                         }
> >                 }
> >         }
> >}
>
>
>
>----------------------------------------------------------------------
>To UNSUBSCRIBE, email to [EMAIL PROTECTED]
>with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
>
>
>
>
>----------------------------------------------------------------------
>To UNSUBSCRIBE, email to [EMAIL PROTECTED]
>with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to