On Oct 5, 2:04 am, Chris <
christian.k...@gmail.com> wrote:
> Question 1: if the stack size is 1MB and if it is possible to create
> 801 threads, does it mean that the virtual memory for user apps is
> ~800MB ? The phone only has 192MB of RAM.
From build/core/prelink-linux-arm.map:
# 0xC0000000 - 0xFFFFFFFF Kernel
# 0xB0100000 - 0xBFFFFFFF Thread 0 Stack
# 0xB0000000 - 0xB00FFFFF Linker
# 0xA0000000 - 0xBFFFFFFF Prelinked System Libraries
# 0x90000000 - 0x9FFFFFFF Prelinked App Libraries
# 0x80000000 - 0x8FFFFFFF Non-prelinked Libraries
# 0x40000000 - 0x7FFFFFFF mmap'd stuff
# 0x10000000 - 0x3FFFFFFF Thread Stacks
# 0x00000000 - 0x0FFFFFFF .text / .data / heap
It doesn't always work out quite this way, but the key point is that
the virtual address space is not a wide-open world. To see where the
space is actually going, put a "sleep" call in your program (or
SIGSTOP it) and then look at /proc/<pid>/maps to see how space is laid
out.
FWIW, on one of my devices I just created 2000 threads from a quick
test program. Threads allocated from Dalvik have the 1MB native stack
and a 12KB interpreter stack.
> Question 2: how big is the total virtual memory on Android and what
> kind of memory management is used? I can not imagine how paging should
> work on a phone.
See map above. Paging works exactly as you'd expect. Swapping, on
the other hand, is totally disabled.