Dealing with file descriptor leak in Eclipse + CDT

Current eclipse builds have the very nasty tendency to leak file descriptors to /usr/share/mime/globs (especially when using CDT). After a while you hit the max fd limit and eclipse will refuse to save your file (and workbench state).

Luckily, under linux you can save the day using ‘gdb’:

  1. Find offending fd’s:
cd /proc/`pidof java`/fd
ls -la|grep globs

Write down about 5 fd numbers

  1. Attach with GDB:
gdb -p `pidof java`

For each fd enter:

p close(XXX)

where XXX is the fd number. Press enter after each line

  1. now type ‘c’ to continue and ‘quit’ to exit
  2. Quickly save your stuff in eclipse and exit/restart

Hooray!