Hi Daniel,

Sorry the weekend got in the way :)

On 29/05/2020 7:01 pm, Daniel Fuchs wrote:
Hi David,

Thanks for the feedback!

On 29/05/2020 00:36, David Holmes wrote:
This seems to be assuming that the GC will clear all SoftReferences when it needs to clear any SoftReference. I don't think that is at all guaranteed. In theory your memory eating loop could be satisfied by clearing only the SoftReference added in the previous iteration of the loop.

I was wondering about that.

I would have expected the fix here to be simply to clear memory ie:

} catch (OutOfMemoryError oome) {
   stop = true;
   memory = null;
   System.gc();
}

Do you think this would be more reliable?
It was my first thought as well - and that was the
first thing I tested, and it seemed to work as well.

If you think it's a better solution I can revert to that.

My rationale for using SoftReference is that they
then could be cleared any time by the GC, and
possibly avoid unexpected OOME elsewhere in the test
machinery.

Yes understood, but it was relying on all soft references being released at the same time.

For these OOME related tests it is hard to come up with a guaranteed way to trigger bugs that stands the test of time. So keep things simple and go with what works now across the set of GCs we are currently support.

Cheers,
David

best regards,

-- daniel

Reply via email to