Using the Android Memory Monitor, especially its "Dump Java Heap" feature, I am currently hunting down memory leaks in my app. On the left of Android Studio's dump/HPROF view there is an option to open "Analyzer Tasks" and there you can tell the machine to "Detect Leaked Activities" and to "Find Duplicate Strings". I am puzzled by the latter option. What does it do and how is it useful? It must be more sophisticated than just helping those clumsy developers among us who put the same string twice into their resources folder. The docs are not very helpful here (if my search was thorough enough) as they only state that it helps in cases "where the target program has strings that repeat values". When would this be the case?
As far as I know, this does just point out duplicated strings in memory. However, this is useful for more than just finding cases where the same string has been entered into more than one resource. For example, as Strings are immutable in Java, you can easily end up with many more instances of strings than you might initially realise. If your app has lots of string concatenation code but dont use StringBuilder, or if your app does any string/text processing, its fairly easy to end up with unexpectedly large amounts of space taken up by strings. But conversely, it can often be a relatively easy optimization to make in order to gain back some space (once you can see what the problem is). So you could say this task is more about memory 'optimization', rather than finding a leak.