On Mon, 6 Sep 2021 07:17:58 GMT, Lin Zang <[email protected]> wrote:
>> This PR rewrite the implementation of the HeapHprofBinWriter, which could
>> simplify the logic of current implementation.
>> please see detail description at
>> https://bugs.openjdk.java.net/browse/JDK-8269685.
>
> Lin Zang has updated the pull request with a new target base due to a merge
> or a rebase. The pull request now contains seven commits:
>
> - Merge branch 'master' into hprof
> - make calculateGlobalJNIHandlesDumpRecordSize abstract
> - code clean up and remove useless methods
> - Merge branch 'master' into hprof
> - fix write size issue
> - Merge branch 'master' into hprof
> - 8269685: Optimize HeapHprofBinWriter implementation
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
line 422:
> 420: };
> 421: }
> 422: hprofBufferedOut = dataOut;
I do not understand why the local variable `dataOut` is needed.
The code will be simpler without it:
OutputStream dataOut = fos;
hprofBufferedOut = dataOut;
if (useSegmentedHeapDump) {
if (isCompression()) {
dataOut = new GZIPOutputStream(fos) {
{
this.def.setLevel(gzLevel);
}
};
}
hprofBufferedOut = dataOut;
}
=====>
hprofBufferedOut = fos;
if (useSegmentedHeapDump) {
if (isCompression()) {
hprofBufferedOut = new GZIPOutputStream(fos) {
{
this.def.setLevel(gzLevel);
}
};
}
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/4666