Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 751579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:40:58+00:00 2026-05-14T14:40:58+00:00

Is there any way to detect and handle whether a Java library is correctly

  • 0

Is there any way to detect and handle whether a Java library is correctly releasing file-handles (via “close”) from within a Java program that is using said library, short of having access to the actual library code and inserting the corresponding “finally close” statements?

If detection is feasible, is there any way to close those file-handles without a reference to the Reader (or FileInputStream) that was reading the file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:40:59+00:00Added an answer on May 14, 2026 at 2:40 pm

    Under Linux and probably some Unixes, you can use lsof to “list open files” opened by an application. You’ll probably see their number increase if your app is leaking file handles. You may even hit the (default) ceiling of 1024 handles eventually.

    Under Windows, there’s some free similar utilities somewhere in the SysInternals suite; I think it’s called “handles” or “fhandles” or such. I’ll go see if I can find it…


    EDIT: Ah, here it is: Handle .


    EDIT: I recently ran into a similar, obscure problem with sockets (which are also a kind of file handle, at least under Linux): Turns out that even if the connection was closed, the associated file handles would not be released until Java did a garbage collection. Our app didn’t go through a lot of memory, so often connection handles would pile up faster than they got cleaned up. We solved the problem by inserting a System.gc() every once in a while. The performance hit was tolerable relative to an out-and-out malfunction when the app ran out of handles.


    EDIT: At its higher level, the JRE’s library is of course “just” Java code, and the source code is AFAIK still being published. So if you’re really desparate, you could write your own wrappers around things like FileInputStream and FileReader, etc. I believe there’s a directory name in the JRE’s file tree into which you can put Jars of “fiddled” classes; it’s called “endorsed” or something like that. That, or you could out-and-out make source code changes to the JRE library code and build your own replacment jars for the Sun (or whatever) libraries. This is obviously not clean or highly portable. I don’t have any experience of my own with such measures, nor would I recommend them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Why not use a frozenset (or set if mutability is… May 14, 2026 at 10:28 pm
  • Editorial Team
    Editorial Team added an answer Sure.. var url = 'resources/css/main.css?detect=#information{width:300px;}'; var matches = url.match(/#([^{]+){([^:]+):([^;]+)/); var… May 14, 2026 at 10:28 pm
  • Editorial Team
    Editorial Team added an answer I'm surprised that pattern works to start with - it… May 14, 2026 at 10:27 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.