Home Technical Talk

MEL fopen problem: Internal file descriptor table is full

Warheart
polycounter lvl 17
Offline / Send Message
Warheart polycounter lvl 17
I’m running into this issue and was wondering if anyone else had encountered it.

Basically I have bit of mel script that’s batch processing a load of maya files and writing data to text files. After around 180 files I get a warning saying “Internal file descriptor table is full” and the next time “fopen” is called after that warning it fails to open the file for writing.

I have tried to reproduce this by simply making a loop that “fopen"s, “fprint"s and “fclose"s but it didn’t happen in that case even after 2000 loops. I think it must be related to the amount of data written but I’ve been unable to narrow it down more than that.

Does anyone know what exactly this “internal file descriptor table” is? I’m guessing it’s either the software buffer that gets written to before fprint writes to disk (makes more sense if it’s related to the volume of data written) or it’s simply a list of file IDs that’s getting to its limit.

Any suggestions as to how I might avoid filling up this buffer or a way to flush it etc. would be much appreciated.

Thanks.

Replies

  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    It sounds like your files aren't being closed properly (which is why your "fopen" -> "fprint" -> "fclose" loop didn't hit the problem, since it's simple and fclose is getting called correctly every time).

    Last time I had this problem it was because the script was hitting some case inside the code where it'd skip or error out before the fclose was ever called, so the file was being left open.

    Basically the only way to fix this is to make sure that all cases of your script erroring out (or returning) include a call to "fclose", otherwise your file will never get closed and will result in filling up the file descriptor table.
  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    Hmm ok. I was pretty sure that the only case where fclose wouldn't get called was if fopen returned 0 (could not open) in this script... I'll have a look again to make sure and come back with the findings. That would be embarassing if that's what it was...

    Thanks for the help, this has been driving me mad :P
  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    Yep, you're right. I missed an fclose in the read function. :poly139:

    Easy once I knew what to look for. Thanks again.
Sign In or Register to comment.