status-im / syng-client

The Mobile Client for the Ethereum Network DEPRECATED
Other
11 stars 4 forks source link

Fix Memory Leak #1

Closed 0xc1c4da closed 9 years ago

0xc1c4da commented 9 years ago

There is essential problems in memory menagement. EthereumConnector object (which is static) offen leaks the fragment and activity instances preventing garbage collector to

release the memory. It causes the sometimes outofmemoryexceptions or simply UI lags. i used LeakCanary library from Square to detect the problem nature. (https://github.com/square/leakcanary)

LOG example:

08-04 http17:09:32.338 19913-21894/io.syng D/LeakCanary﹕ * io.syng.fragment.ConsoleFragment has leaked: 08-04 http17:09:32.338 19913-21894/io.syng D/LeakCanary﹕ * GC ROOT static

io.syng.fragment.ConsoleFragment.sEthereumConnector 08-04 http17:09:32.338 19913-21894/io.syng D/LeakCanary﹕ * references

org.ethereum.android.service.EthereumConnector.handlers 08-04 http17:09:32.338 19913-21894/io.syng D/LeakCanary﹕ * references java.util.ArrayList.array 08-04 http17:09:32.338 19913-21894/io.syng D/LeakCanary﹕ * references array java.lang.Object[].[0] 08-04 http17:09:32.338 19913-21894/io.syng D/LeakCanary﹕ * leaks io.syng.fragment.ConsoleFragment instance 08-04 http17:09:32.338 19913-21894/io.syng D/LeakCanary﹕ [ 08-04 http17:09:32.338 19913:21894 D/LeakCanary ]

I will check what i can do from my side, but i suppose the problem is in org.ethereum.android.service.EthereumConnector

adrian-tiberius commented 9 years ago

Moved ethereumConnector to application class to make it easily available to all activities. I think this should also fix the memory leak.