Giter VIP home page Giter VIP logo

leakcanarybinding's Introduction

nuget link

LeakCanaryBinding

This is a Xamarin.Android Binding for the Square.LeakCanary library. A memory leak detection library for Android and Java.

โ€œA small leak will sink a great ship.โ€ - Benjamin Franklin

screenshot

Getting started

In your Application class:

    [Application]
    internal class MainApplication : Application
    {
        private RefWatcher _refWatcher;

        protected MainApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {
        }

        public override void OnCreate()
        {
            base.OnCreate();
            SetupLeakCanary();
        }

        protected void SetupLeakCanary()
        {
            if (LeakCanaryXamarin.IsInAnalyzerProcess(this))
            {
                // This process is dedicated to LeakCanary for heap analysis.
                // You should not init your app in this process.
                return;
            }
            _refWatcher = LeakCanaryXamarin.Install(this);
        }
    }

You're good to go! LeakCanary will automatically show a notification when an activity memory leak is detected in your debug build.

Questions? Check out the official LeakCanary FAQ!

Customizing LeakCanary

To customize LeakCanary, see the wiki of LeakCanary.

LeakCanary Modifications for Xamarin

Unfortunately, there is a bug in Xamarin.Android, which does not allow to have a custom Application class and a Service running within an isolated process. Therefore it was required to use a modified version of the LeakCanaray library for the binding to work.

leakcanarybinding's People

Contributors

crehmann avatar

Stargazers

 avatar Stephen Price avatar ShikaTech avatar Iqbal Ansari avatar Michele avatar

Watchers

James Cloos avatar  avatar

leakcanarybinding's Issues

Leak tree always shows only single item pointing to application class

I appreciate you working on this, as I really miss LeakCanary since I moved to Xamarin Android.

However, it seems that there is something wrong with the leak notifications, as for every activity/fragment, I get something like the following notification:

grafik

There is never a real memory tree, only one single object that points to the main app. (Clicking the + Icon does not change this)

I think there are only two possibilities here:

  1. There is no leak, but the notification shows up anyway
  2. There is a memory leak, but the retrival of the memory tree is somehow not working or incomplete.

Any thoughts?

Tested on

  • Emulator (Nexux 9, API 23)
  • Nexus 5 (Android 6.0)
  • Pixel XL (Anroid 8.1 - side note: notifications don't show up BTW, most likely because the app didn't register a proper notification channel as required on API 26+)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.