Using LeakCanary on a non Android application

Vanja Keglevic :

Can LeakCanary be used on a non Android application? For example, in a JavaFx application?

Stephen C :

The short answer is no it can't.


The LeakCanary documentation site says this:

LeakCanary’s knowledge of the internals of the Android Framework gives it a unique ability to narrow down the cause of each leak, helping developers dramatically reduce OutOfMemoryError crashes.

From this, we infer that it is the tool's knowledge of Android that is what distinguishes it from a generic leak detector.

Then we look at the source code repo on Github, there are a number of directories in the source tree for Android support, but nothing obvious that provides support for any other frameworks (Swing, JavaFX, SWT, etc).

Finally, LeakCanary support for JavaFX has been requested on the project's issue tracker, and the request has been declined as "not a priority".

It is not inconceivable that someone could apply the approach used by LeakCanary to other frameworks. Or even extend LeakCanary to support other frameworks. But there is no sign anyone has done this. (That I can find.)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=471536&siteId=1