Detect Memory Leaks with LeakCanary
realm.io
realm.io
If you look under "no-op dependency" you'll find a solution to the issue you're describing.
I've found it useful to have a leak canary specific build flavor or type, which only I ever see. For all other debug / production build leak canary is not initialized.