I've got the following code to test:
import java.math.BigInteger;
import java.util.Random;
public class TestBigInteger {
public static void main(String[] args) {
BigInteger bigInteger = BigInteger.probablePrime(32, new Random())
.multiply(BigInteger.probablePrime(32, new Random()));
BigInteger n = BigInteger.probablePrime(20, new Random());
while (!Thread.interrupted()) {
bigInteger.mod(n);
}
}
}
And I've got the following plot from jconsole:
Why is that happening? Why mod operation takes really a lot of memory, if my bigInteger
is only 64 bit length?