commons httpclient - PutMethod run OutOfMemoryError ??

Discussion in 'Java' started by Bastian, Dec 6, 2005.

  1. Bastian

    Bastian Guest

    hello,

    when running the follwoing code, i get a error message from
    SimpleHttpConnectionManager.releaseConnection:

    WARNING: SimpleHttpConnectionManager being used incorrectly. Be sure
    that HttpMethod.releaseConnection() ist always called and that only one
    thread and/or method is this connection manager at a time.

    And it throws java.lang.OutOfMemoryError

    This happend only if try to upload bigger files (prob > 50MB) smaller
    textfiles are no proplem with this code.


    What can i do to solve that problem and what is the problem in detail?


    thx
    bastian


    Code:

    PutMethod method2 = null;
    try {
    method2 = new PutMethod(url+"/"+remote);
    method2.setRequestEntity(
    new InputStreamRequestEntity(

    new FileInputStream( local ) ) );
    } catch (FileNotFoundException e) {
    log.warning("File doesnt exist: " + local);
    e.printStackTrace();
    return false;
    }
    long start = 0, time = 0, bytes = local.length();
    try {
    // Execute the method.
    start = System.currentTimeMillis();
    int statusCode =
    httpclient.executeMethod(method2);
    time = System.currentTimeMillis() - start;
    if (statusCode != HttpStatus.SC_CREATED
    && statusCode !=
    HttpStatus.SC_OK) {
    log.warning("PutMethod failed: " +
    method2.getStatusLine() + " Statuscode="+statusCode);
    } else
    ret = true;
    } catch (HttpException e) {
    log.severe("Fatal protocol violation: " +
    e.getMessage());
    e.printStackTrace();
    } catch (IOException e) {
    log.severe("Fatal transport error: " +
    e.getMessage());
    e.printStackTrace();
    } finally {
    // Release the connection.
    method2.releaseConnection();
    }
    Bastian, Dec 6, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2ZQ==?=

    Serialize session state & OutOfMemoryError?

    =?Utf-8?B?RGF2ZQ==?=, Sep 8, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,514
    =?Utf-8?B?RGF2ZQ==?=
    Sep 8, 2005
  2. Gamas
    Replies:
    0
    Views:
    2,293
    Gamas
    Feb 4, 2005
  3. Replies:
    2
    Views:
    1,779
  4. Joe Linux
    Replies:
    0
    Views:
    618
    Joe Linux
    Sep 15, 2006
  5. Sebastian
    Replies:
    1
    Views:
    1,343
    Sebastian
    Jun 22, 2011
Loading...

Share This Page