For instance we have two same android devices with 2GB RAM each (the energy-dependant memory).
Device 1: 1GB RAM is busy by running applications and 1GB RAM is free.
Device 2: 2GB RAM are busy by running applications.
Imagine that CPU is not used by the apps runing or is used just a little. The memory also remains unchanged (not rewriting frequently). Will the device 2 lose power (to 0% battery charge) much faster than device 1?
Please explain this issue to me, I am really curious about java-android memory power usage.
Simple answer is: no.
Let's iterate over options how having less memory may cost you less power:
The most realistic scenario is that having more memory available means more disk/flash card cache hits and thus less access to these power hungry devices. More memory also means lesser incentive to run GC and that saves you CPU time (and may cost even more if your system uses swap/zram, most phones don't have swap). You will probably save some power here.
The other option is that the phone has more memory chips and the kernel is smart enough to compact the memory and make the unused chips idle. The technology is here, for hotswapping of RAM in servers, but I have not yet heard of phone using it.
Finally you may be convinced that the cost of keeping zeroes in memory might somehow be lower than keeping random data (the RAM has to refresh its contents periodically). Let's do some crazy tests on laptop with 3GB of RAM. Free gives us:
total used free shared buffers cached Mem: 3077800 2760220 317580 40308 219036 1137020 -/+ buffers/cache: 1404164 1673636 Swap: 2047996 7492 2040504
And counting pages full of zero in /dev/kmem gives us: Zeroed = 34, used = 786398. Let's try dropping the caches:
sync && echo 3 > /proc/sys/vm/drop_caches && free total used free shared buffers cached Mem: 3077800 1686792 1391008 44884 1248 326864 -/+ buffers/cache: 1358680 1719120 Swap: 2047996 7492 2040504
And the result stays the same: Zeroed = 34, used = 786398. Linux does not zero out free memory and on modern kernels there will probably not be a lot of pages full of zeros, because they all map to the same physical memory. The machinism is called zero-page (http://lwn.net/Articles/340370/)