Using rxactivity memory, Rxlifecycle2 still works, you can see that the memory used is much smaller.
Private voidCreatesingle () { single<List<String>> Tvshowsingle = single.fromcallable (NewCallable<list<string>>() {@Override PublicList<string> Call ()throwsException {List<String> list =NewArraylist<string>(); inti = 0; while(I < 800000) {List.add (string.valueof (i)); LOG.D (TAG, string.valueof (i)); I++; } returnlist; } }); Tvshowsingle. Subscribeon (Schedulers.io ()). Observeon (Androidschedulers.mainthread ()) . Compose ( This. Bindtolifecycle ()). Subscribe (NewDisposablesingleobserver<list<string>>() {@Override Public voidOnsuccess (@NonNull list<string>strings) {LOG.D (TAG,"A35"); Mtextview.settext (Strings.size ()+""); } @Override Public voidOnError (@NonNull throwable e) {}}); }
Create a comparison of memory operation function, if the normal activity, the estimated size of 64M, the Activiy finished off in advance, then after the execution will access the content of the view, the content of the view is empty
Call a function in the OnCreate place
Createsingle ();
Finish (); Call this function will automatically close the activity interface, the program's interface exits, but the background of the process is still not closed, is still running, is the continuous printing log out.
The process of the program is not closed, still running in the background, has been occupying memory resources, no release, no use. Compose (This.bindtolifecycle ()), memory has been maintained at 64M size has remained unchanged, no release
Android Rxjava Memory leak