RFR: JDK-8280002: jmap -histo may leak stream

Thomas Stuefe stuefe at openjdk.java.net
Fri Jan 14 13:26:24 UTC 2022


On Fri, 14 Jan 2022 12:52:11 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> This is not as trivial, AFAICS. Note that the existing code `delete fs` after checking `if (os != NULL && os != out)`. Does it mean this patch can effectively `delete out`?

Thanks for looking at this. No, it is safe.

`fs` is a temporary fileStream which may or may not be NULL. It is safe to `delete` it. The delete you mention could be moved out of the condition and it would still be fine. The condition is only really needed for the output which should only appear if you don't write to stdout.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7078


More information about the serviceability-dev mailing list