Android Rxjava Memory leak

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.