"java.io.IOException: Too many open files" rlim_fd_cur set to max

Discussion in 'Java' started by Cathy Hui, Mar 4, 2005.

  1. Cathy  Hui

    Cathy Hui Guest

    I am getting the "java.io.IOException: Too many open files" error when
    running some program on a Solaris 8. Pls note, I have already set
    ulimit to max. How can I avoid this problem? Thanks in advance for
    answering my question.

    Here is the output from "uname -a":

    SunOS ax-pb2 5.8 Generic_108528-19 sun4u sparc SUNW,Ultra-5_10

    Here is what I have on the /etc/system:

    set rlim_fd_cur = 4096
    set rlim_fd_max = 4096
    Cathy Hui, Mar 4, 2005
    #1
    1. Advertising

  2. Cathy  Hui

    Rhino Guest

    "Cathy Hui" <> wrote in message
    news:...
    > I am getting the "java.io.IOException: Too many open files" error when
    > running some program on a Solaris 8. Pls note, I have already set
    > ulimit to max. How can I avoid this problem? Thanks in advance for
    > answering my question.
    >

    Open fewer files?

    Close files before you open new ones?

    Do you really need 4096 files open at the same time??

    Rhino
    Rhino, Mar 4, 2005
    #2
    1. Advertising

  3. Cathy  Hui

    Wiseguy Guest

    "Cathy Hui" <> scribbled on the stall wall:
    > How can I avoid this problem?


    Don't open so many files at once. :^P

    Seriously, to get any useful answer to this questions you need to tell us
    how many files you are openning and maybe post some example code (as long
    as it's not too long).

    A description of what exactly you are trying to do would not hurt.


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    Wiseguy, Mar 4, 2005
    #3
  4. Cathy  Hui

    Dotty Guest

    "Cathy Hui" <> wrote in message
    news:...
    > I am getting the "java.io.IOException: Too many open files" error when
    > running some program on a Solaris 8. Pls note, I have already set
    > ulimit to max. How can I avoid this problem? Thanks in advance for
    > answering my question.
    >
    > Here is the output from "uname -a":
    >
    > SunOS ax-pb2 5.8 Generic_108528-19 sun4u sparc SUNW,Ultra-5_10
    >
    > Here is what I have on the /etc/system:
    >
    > set rlim_fd_cur = 4096
    > set rlim_fd_max = 4096
    >


    Gee, how about closing some files.
    Dotty, Mar 4, 2005
    #4
  5. Cathy  Hui

    Cathy Hui Guest

    The script processes one profile each time. And each profile has at
    least 2 files to process (just rename them, it will take just
    milli-seconds). There are 1276 profiles on this process.

    Here is the code, pls advise. thanks!

    ===========================================

    private int moveConfFiles(String pPath, String workPath,
    boolean sign) {
    File dir = new File(workPath);
    File vFile = null;
    if (dir.exists()) {
    File[] fileList = dir.listFiles();
    int numFile = fileList.length;
    if (numFile > 0) {
    for (int i = 0; i < numFile; i++) {
    if (fileList == null ||
    (!fileList.isFile())) {
    return MOVE_FAILED;
    }
    vFile = new File(pPath +
    fileList.getName());
    if (vFile != null && vFile.exists()) {
    vFile.delete();
    }
    if (!fileList.renameTo(vFile)) {
    return MOVE_FAILED;
    }

    }
    }
    }
    return MOVE_SUCCESSFUL;
    }
    Cathy Hui, Mar 4, 2005
    #5
  6. Cathy  Hui

    Cathy Hui Guest

    Correction from the last mesg:

    i.e. each profile has at least 4 files to process
    Cathy Hui, Mar 4, 2005
    #6
  7. Cathy  Hui

    Wiseguy Guest

    "Cathy Hui" <> scribbled on the stall wall:
    > The script processes one profile each time. And each profile has at
    > least 2 files to process (just rename them, it will take just
    > milli-seconds). There are 1276 profiles on this process.
    >
    > Here is the code, pls advise. thanks!
    >
    > ===========================================
    >
    > private int moveConfFiles(String pPath, String workPath,
    > boolean sign) {
    > File dir = new File(workPath);
    > File vFile = null;
    > if (dir.exists()) {
    > File[] fileList = dir.listFiles();
    > int numFile = fileList.length;
    > if (numFile > 0) {
    > for (int i = 0; i < numFile; i++) {
    > if (fileList == null ||
    > (!fileList.isFile())) {
    > return MOVE_FAILED;
    > }
    > vFile = new File(pPath +
    > fileList.getName());
    > if (vFile != null && vFile.exists()) {
    > vFile.delete();
    > }
    > if (!fileList.renameTo(vFile)) {
    > return MOVE_FAILED;
    > }
    >
    > }
    > }
    > }
    > return MOVE_SUCCESSFUL;
    > }
    >


    my only suggestion is to save dir.listFiles() as an array of Strings
    instead of an array of Files. Then convert the String representation
    back to File when you actually need it. I suspect that File [] is
    causing you to run out of file handles. You might also want to
    evaluate the scope of vFile and see if you can figure out a way to
    force object destruction when the old object reference is no longer
    needed.




    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    Wiseguy, Mar 4, 2005
    #7
    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. -a-geek.net

    Set Start Page to max size

    -a-geek.net, Dec 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,141
    -a-geek.net
    Dec 28, 2004
  2. Summercool
    Replies:
    9
    Views:
    879
    dorayme
    Oct 23, 2007
  3. _pr0p
    Replies:
    2
    Views:
    4,798
    _pr0p
    May 14, 2008
  4. Greg Ferris

    Textarea max rows and max characters per row

    Greg Ferris, Jan 16, 2004, in forum: Javascript
    Replies:
    2
    Views:
    576
    Greg Ferris
    Jan 16, 2004
  5. kriton
    Replies:
    0
    Views:
    334
    kriton
    Apr 22, 2005
Loading...

Share This Page