<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I always meant to ask, why is it that we chose to dedicate the beginning of the memory chunk to NMT, and not the end?<br>
<br>
If we used the end, then in this case with an unbalanced malloc/free, we would still be OK.<br>
<br>
The end seems more natural to me and either way we need to track the size, and moreover, in the current case, we need the size of the header as well.<br>
<br></blockquote><div><br></div><div>Can't use the end, since you don't know the size of the block in free(). If you had the size, you wouldn't need the malloc header in the first place, since its main purpose, apart from accounting tags, is to give you the size.</div><div><br></div><div>Cheers, Thomas<br></div><div>Â </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
cheers<br>
<br>
> <br>
> (Side note: our internal tracker sidesteps this problem entirely by<br>
> avoiding malloc headers. Instead, it uses a hash tables to match pointers<br>
> with their meta information. But that has other cons and I do not plan to<br>
> change the way NMT works.)<br>
> <br>
> Performance-wise, instead of calling into the libc directly, we would call<br>
> into the hotspot, then into the libc. That indirection will cost some<br>
> cycles. If NMT is off, there does not happen much more beside the real<br>
> malloc call. Even NMT summary mode is very cheap. So I don't expect this to<br>
> be a problem but will run performance tests.<br>
> <br>
> --------<br>
> <br>
> My patch [1] works and can be built and tested. But the PR is still a work<br>
> in progress. I just wanted to make sure nobody generally objects to my work.<br>
> <br>
> Cheers, Thomas<br>
> <br>
> [1] <a href="https://github.com/openjdk/jdk/pull/10988" rel="noreferrer" target="_blank">https://github.com/openjdk/jdk/pull/10988</a><br>
> [2] <a href="https://github.com/SAP/SapMachine/wiki/SapMachine-MallocTracer" rel="noreferrer" target="_blank">https://github.com/SAP/SapMachine/wiki/SapMachine-MallocTracer</a><br>
> [3] <a href="https://mail.openjdk.org/pipermail/hotspot-dev/2018-November/035358.html" rel="noreferrer" target="_blank">https://mail.openjdk.org/pipermail/hotspot-dev/2018-November/035358.html</a><br>
</blockquote></div></div>