Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leaks, the ticket to end all tickets #335

Closed
spyhunter99 opened this issue Jun 18, 2016 · 1 comment
Closed

Memory leaks, the ticket to end all tickets #335

spyhunter99 opened this issue Jun 18, 2016 · 1 comment
Labels

Comments

@spyhunter99
Copy link
Collaborator

This ticket shall cover the multitude of memory leaks within osmdroid. These leaks (typically) only occur when destroying and creating the mapview multiple times in a session. Related tickets #57 #328 #318 #283 and probably many others.

I've been silently working on this issue for a few days. Here's a few notes on the issue.

The AS 2.1 and newer apparently no longer has the memory and cpu telemetry in the IDE. Grrr
Finding root causes of leaks is a real pain with lots of guessing and checking
Leaks behave differently on different versions of android.
Many of the leaks, but not all, are really on present issues for those that run osmdroid in a fragment
Many of the leaks only affect the sample application. But if the sample app "is the right way do use osmdroid", then we should definitely fix it.

To setup the test environment, I've been modifying the unit tests to run the same example fragment 100 times with memory counters on start and stop. I've also adding instrumentation to the aar library to keep counters of OOM exceptions, which is used to force and earlier termination of the tests. In the future, it may be useful to developers that use osmdroid to detect error conditions. Currently, many of the internal error states simply are not accessible programmatically anywhere.

This ticket also reduces the number of static variables used within many of the overlay classes to enable those variables to be GC'd. It also covers the LRUCache which doesn't get purged when the mapview is destroyed, which is clearly a problem.

More information to come

spyhunter99 added a commit that referenced this issue Jun 22, 2016
spyhunter99 added a commit that referenced this issue Jun 24, 2016
spyhunter99 added a commit that referenced this issue Jul 1, 2016
# Conflicts:
#	osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/TileWriter.java

also fixes for more memory leaks in FolderOverlay
spyhunter99 added a commit that referenced this issue Jul 1, 2016
spyhunter99 added a commit that referenced this issue Jul 4, 2016
spyhunter99 added a commit that referenced this issue Jul 5, 2016
… after running much longer tests, it revealed that there was still another leak with the ExampleActivity which is now fixed

NOJIRA - removing the silly copy sources task in favor of a source redirector (gradle build only)
NOJIRA - adding Leak Canary and ACRA for leak testing and crash logging
spyhunter99 added a commit that referenced this issue Jul 5, 2016
…pears to be a timing issue. This patch should resolve it and reduce the wait time
spyhunter99 added a commit that referenced this issue Jul 5, 2016
spyhunter99 added a commit that referenced this issue Jul 5, 2016
spyhunter99 added a commit that referenced this issue Jul 6, 2016
# Conflicts:
#	OpenStreetMapViewer/src/main/java/org/osmdroid/samplefragments/SampleFactory.java
@spyhunter99
Copy link
Collaborator Author

near ready for merging

spyhunter99 added a commit that referenced this issue Jul 9, 2016
# Conflicts:
#	OpenStreetMapViewer/src/main/java/org/osmdroid/samplefragments/SampleFactory.java
#	osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/IFilesystemCache.java
#	osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/SqlTileWriter.java
#	osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/TileWriter.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant