G1 maintains a pin count value for every region that indicates how many times an object has been pinned in a region.
Typically these calls to pin/unpin (Get/ReleasePrimitiveCritical) need to be paired exactly to avoid memory leaks (the region can't be reclaimed while the pin count != 0).
Currently gc+heap+region=trace provides a way to monitor the region's pin count, allowing a user to track pin counts. This makes debugging issues in that area possible, but tedious.
For a bit more convenience we could add a pin count "red zone", particularly in the negative range (-1 ... -4096 - random numbers) where if the aggregated pin count is within that area, error out.
Maybe guarded with CheckJNI or something flag.