jira-importer opened a new issue, #820:
URL: https://github.com/apache/httpcomponents-core/issues/820

   **[Halo 
chen](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=rockch)** 
opened 
**[HTTPCORE-118](https://issues.apache.org/jira/browse/HTTPCORE-118?redirect=false)**
 and commented
   
   Thanks very much for your contributions.
   I use your httpcore to develop a embed web application, very well, I think.
   But, when i do some stress test, i find a strange issue, please see my test 
case:
   
   public class SendToIA implements Runnable {
   String[] args;
   SendToIA( String[] args )
   {
   this.args = args;
   }
   public void run()
   {
   try {
   FileInputStream fis = new FileInputStream("a.txt");
   int len = fis.available();
   byte[] buf = new byte[len];
   fis.read(buf);
   fis.close();
   String ReuestHead = "POST /TerminalLocationNotification HTTP/1.1\r\nHOST: 
LOCALHOST\r\nContent-Length: ";
   String ReuestLen = String.valueOf(len) + "\r\n\r\n";
   String RequestBody = new String(buf);
   String httpRequest = ReuestHead + ReuestLen + RequestBody;                   
   String host = "localhost";
   int port = 8086;
   if( args.length == 1 )
   {
   host = args[0];
   }
   else if( args.length == 2 )
   {
   host = args[0];
   port = Integer.parseInt( args[ 1 ] );
   }
   
                System.out.println(new java.util.Date());
       
                for (int i = 0; i < 20000; i++) {
                        Socket connection = new Socket( host, port );
                        connection.setReuseAddress( true );
                        PrintWriter out = new 
PrintWriter(connection.getOutputStream(), true);
                        out.print(httpRequest);
                        out.flush();
                        connection.close();             
                        System.out.print("\b\rcont:"+i);
                }
                System.out.println(new java.util.Date());
        } catch (SecurityException e) {
                e.printStackTrace();
        } catch (Exception e) {
                e.printStackTrace();
        }
       }
       public static void main(String[] args) throws IOException {
        int threadcount = 1;
        if( args.length == 3 )
        {
                threadcount = Integer.parseInt( args[ 2 ] );
        }
        Thread[] t = new Thread[ threadcount ];
        for( int i = 0 ; i < threadcount ; i ++ )
        {
                new Thread( new SendToIA( args )        ).start();
        }
        for( int i = 0 ; i < threadcount ; i ++ )
        {
                try{t[i].join();}catch( Exception e ){}
        }
       }
   
   }
   
   Unfortunately, the application was crashed.
   The first , I think my application has some mistake. so I run the example( 
org.apache.http.examples.nio.NHttpServer) in the HttpCore binary package. Oh,No!
   The same issue was occured!
   Why? I found the memory usage of the application reach 170M!!, and then I 
add the JVM parameter -Xmx256M.Okay, the application can running continue. but 
after a long time, the memory usage of the application reach 256M and then the 
same thing was occured! So , I think that the HttpCore has some memory leak.
   
   Can you give me some advices to resolve this issue? or I have some mistakes?
   
   details of error occured:
   ...
   
   Exception in thread "I/O reactor worker thread 2" 
java.lang.OutOfMemoryError: Java heap space
   ....
   java.lang.NullPointerException
   at 
org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.verifyWorkers(AbstractMultiworkerIOReactor.java:136)
   at 
org.apache.http.impl.nio.reactor.DefaultListeningIOReactor.execute(DefaultListeningIOReactor.java:111)
   ....
   Exception in thread "I/O reactor worker thread 8" 
java.lang.OutOfMemoryError: Java heap space
   Exception in thread "Thread-6" java.lang.OutOfMemoryError: Java heap space
   
   Sorry , I'm chinese , my english is bad, may be i haven't explain the issue 
clearly. but I need your help.
   
   
   ---
   
   **Affects:** 4.0-alpha5
   
   **Attachments:**
   - [a.txt](https://issues.apache.org/jira/secure/attachment/12366792/a.txt) 
(_1.36 kB_)
   - 
[SendToIA.java](https://issues.apache.org/jira/secure/attachment/12366822/SendToIA.java)
 (_4.43 kB_)
   - 
[SendToIA.java](https://issues.apache.org/jira/secure/attachment/12366793/SendToIA.java)
 (_2.06 kB_)
   - 
[snapshot.jpg](https://issues.apache.org/jira/secure/attachment/12366821/snapshot.jpg)
 (_157.60 kB_)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to