I found that using the same string leaks memory:
String txt = "aaa";
txt = "bbb";
txt = "ccc";
The question is whether there will be a memory leak if you use a Map instead of Strings:
Map<String, String> map = new HashMap<>();
map.put("txt", "aaa");
map.put("txt", "bbb");
map.put("txt", "ccc");