Working in real device and not in simulator. The reason from developer site is
The Android Runtime (ART) and Dalvik virtual machine use paging and memory-mapping (mapping) to manage memory. This means that any memory an app modifies—whether by allocating new objects or touching mapped pages—remains resident in RAM and cannot be paged out. The only way to release memory from an app is to release object references that the app holds, making the memory available to the garbage collector.
Garbage collection
A managed memory environment, like the ART or Dalvik virtual machine keeps track of each memory allocation.
In a virtual machine, it's happening but in a Physical device, the result is different. The Garbage collector cleans or needs to clean whatever is not in use anymore.