-
Notifications
You must be signed in to change notification settings - Fork 112
/
index.apt
56 lines (41 loc) · 2.24 KB
/
index.apt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
What is this?
This little Java agent is a tool that keeps track of where/when/who
opened files in your JVM. You can have the agent trace these operations
to find out about the access pattern or handle leaks, and dump the
list of currently open files and where/when/who opened them.
In addition, upon "too many open files" exception, this agent will
dump the list, allowing you to find out where a large number of
file descriptors are in use.
For a long running application, you can have it run a mini HTTP server
to access the information on demand. This tool can be also loaded as a regular
dependency jar and the list of the table can be
{{{http://file-leak-detector.kohsuke.org/apidocs/index.html?org/kohsuke/file_leak_detector/Listener.html}programmatically accessed}}.
Usage
Without any option, this tool silently records file open/close operations
and upon "too many open files" exception, the table will be dumped to
stderr.
-------------
$ java -javaagent:path/to/file-leak-detector.jar ...your usual Java args follows...
-------------
There are several options you can pass to the agent. For example, to
dump the open file handles when the total number reaches 200, you can do the following:
-------------
$ java -javaagent:path/to/file-leak-detector.jar=threshold=200 ...your usual Java args follows...
-------------
Or have it run a mini HTTP server so that you can access the information
from your browser, do the followind and open http://localhost:19999/:
-------------
$ java -javaagent:path/to/file-leak-detector.jar=http=19999 ...your usual Java args follows...
-------------
Use the help option to see the help screen for the complete list of options.
-------------
$ java -javaagent:path/to/file-leak-detector.jar=help
-------------
Attaching after VM startup
When run as a regular jar file, this tool can be used to attach the detector into other JVMs
on the same system. You specify the JVM by its PID. The following example attaches
the file leak detector to the pid 1500. Options can be specified in the 2nd argument
in the same format you do to the agent.
-------------
$ java -jar path/to/file-leak-detector.jar 1500 threshold=200,strong
-------------