I'm trying to integrate web3j in an android application. But the library gives an Out Of Memory exception when loading the wallet file:
Credentials credentials = WalletUtils.loadCredentials("password", walletFile)
This is the exception:
java.lang.OutOfMemoryError: Failed to allocate a 268435468 byte allocation with 8050708 free bytes and 244MB until OOM
This seems to be the culprit:
//com.lambdaworks.crypto.SCrypt#scryptJ
byte[] V = new byte[128 * r * N]; // r: 8, N: 262144, V = byte[268435456]
I know that the credentials can be loaded because another project, Ether Wallet, uses web3j and is able to load the same wallet file. Can someone tell me how to solve this?
useFullScrypt
which was set totrue
setting it tofalse
solved the problem. Didn't have time yet to investigate the problem but as I checked the KPF params are different in those cases.