Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.OutOfMemoryError on android #448

Closed
Giudici-a opened this issue Mar 26, 2018 · 6 comments
Closed

java.lang.OutOfMemoryError on android #448

Giudici-a opened this issue Mar 26, 2018 · 6 comments

Comments

@Giudici-a
Copy link

Hi,

I try to use your library to create my own wallet app just to learn how it work on android, but i get a strange exception when i tried to loadCredentials like this:
private Boolean getWallet(String password, File dir) throws Exception { this.myWallet = WalletUtils.loadCredentials(password, dir); this.address = this.myWallet.getAddress(); Log.d(TAG, this.address); //a tester return this.address == null; }

I get this exception : java.lang.OutOfMemoryError, i'am sure my wallet file is valid because i select it from a FileDialog that i made and it always worked before. (and i did some test today to be sure it was not that, and the exception should be different if it was the problem).

i saw other issues about this subject but the solution doesn't work for me.

So if someone can help me it could be wonderful.

Thanks for your reading.

@iikirilov
Copy link
Contributor

@Giudici-a could you tag the possibly related issue and post a full stacktrace

@Giudici-a
Copy link
Author

Giudici-a commented Mar 26, 2018

Hi, of course:

3-26 17:35:10.796 14444-14444/com.example.aureliengiudici.ethrade E/AndroidRuntime: FATAL EXCEPTION: main java.lang.OutOfMemoryError at org.spongycastle.util.Arrays.clone(Arrays.java:602) at org.spongycastle.crypto.generators.SCrypt.SMix(SCrypt.java:126) at org.spongycastle.crypto.generators.SCrypt.MFcrypt(SCrypt.java:87) at org.spongycastle.crypto.generators.SCrypt.generate(SCrypt.java:66) at org.web3j.crypto.Wallet.generateDerivedScryptKey(Wallet.java:136) at org.web3j.crypto.Wallet.decrypt(Wallet.java:214) at org.web3j.crypto.WalletUtils.loadCredentials(WalletUtils.java:82) at com.example.aureliengiudici.ethrade.Contracts.WalletConfiguration.getWallet(WalletConfiguration.java:108) at com.example.aureliengiudici.ethrade.Contracts.WalletConfiguration.start(WalletConfiguration.java:56) at com.example.aureliengiudici.ethrade.MainActivity.openWalletFile(MainActivity.java:135) at com.example.aureliengiudici.ethrade.MainActivity.access$100(MainActivity.java:32) at com.example.aureliengiudici.ethrade.MainActivity$1.fileSelected(MainActivity.java:70) at com.example.aureliengiudici.ethrade.Utils.FileDialog$3.fireEvent(FileDialog.java:116) at com.example.aureliengiudici.ethrade.Utils.FileDialog$3.fireEvent(FileDialog.java:114) at com.example.aureliengiudici.ethrade.Utils.ListenerList.fireEvent(FileDialog.java:177) at com.example.aureliengiudici.ethrade.Utils.FileDialog.fireFileSelectedEvent(FileDialog.java:114) at com.example.aureliengiudici.ethrade.Utils.FileDialog.access$600(FileDialog.java:19) at com.example.aureliengiudici.ethrade.Utils.FileDialog$2.onClick(FileDialog.java:77) at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:963) at android.widget.AdapterView.performItemClick(AdapterView.java:298) at android.widget.AbsListView.performItemClick(AbsListView.java:1128) at android.widget.AbsListView$PerformClick.run(AbsListView.java:2812) at android.widget.AbsListView$1.run(AbsListView.java:3571) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5297) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method)

the function where i do the loadCredentials is the getWallet.

The relative issues : #308 , #299
@iikirilov do you have some ideas ?

@kagile
Copy link

kagile commented Dec 27, 2018

Still happening with
api ('org.web3j:core:4.1.0-android')

Device: Motorola Nexus 6
OS: Andorid Naugat 7.1

@kagile
Copy link

kagile commented Dec 27, 2018

Stacktrace:

E: Throwing OutOfMemoryError "Failed to allocate a 28 byte allocation with 0 free bytes and 3GB until OOM" (recursive case)
E: "RxCachedThreadScheduler-1" daemon prio=5 tid=14 Runnable
E:   | group="main" sCount=0 dsCount=0 obj=0x22c074c0 self=0xb4836c00
E:   | sysTid=28807 nice=0 cgrp=apps sched=0/0 handle=0xb491c680
E:   | state=R schedstat=( 0 0 0 ) utm=259 stm=17 core=1 HZ=100
E:   | stack=0xa4099000-0xa409b000 stackSize=1036KB
E:   | held mutexes= "mutator lock"(shared held)
E:     at org.bouncycastle.util.Arrays.clone(unavailable:-1)
E:     at org.bouncycastle.crypto.generators.SCrypt.SMix(unavailable:-1)
E:     at org.bouncycastle.crypto.generators.SCrypt.MFcrypt(unavailable:-1)
E:     at org.bouncycastle.crypto.generators.SCrypt.generate(unavailable:-1)
E:     at org.web3j.crypto.Wallet.generateDerivedScryptKey(Wallet.java:131)
E:     at org.web3j.crypto.Wallet.decrypt(Wallet.java:197)
E:     at org.web3j.crypto.WalletUtils.loadCredentials(WalletUtils.java:119)
E:     at org.web3j.crypto.WalletUtils.loadCredentials(WalletUtils.java:113)
E:     at com.example.krupal.smartcontractapp.MainActivity.lambda$onCreate$1(MainActivity.java:61)
E:     at com.example.krupal.smartcontractapp.-$$Lambda$MainActivity$fRkwt4x_v4-ifh824OdJn3WdAHQ.apply(lambda:-1)
E:     at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:57)
E:     at io.reactivex.internal.observers.DeferredScalarDisposable.complete(DeferredScalarDisposable.java:82)
E:     at io.reactivex.internal.operators.observable.ObservableFromCallable.subscribeActual(ObservableFromCallable.java:53)
E:     at io.reactivex.Observable.subscribe(Observable.java:12090)
E:     at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
E:     at io.reactivex.Observable.subscribe(Observable.java:12090)
E:     at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
E:     at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
E:     at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
E:     at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
E:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
E:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
E:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E:     at java.lang.Thread.run(Thread.java:818)

@kagile
Copy link

kagile commented Dec 28, 2018

Can anyone please provide a temporary solution to this?

@alexroan
Copy link

alexroan commented Jul 9, 2020

Can anyone please provide a temporary solution to this?

Try this: #299 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants