> I have noticed some unexpected behavior of my Linux 2.4.7 kernel. It appears
> that my user level task is only allowed 512 mallocs before each malloc
> starts getting physical memory. I want to malloc virtual address space and
> only get physical memory when I write to a page. Is this some compiled
> constant in the kernel? Are there any ways to get more? Where can I read
> about such architecture decisions, so other behavior won't be so unexpected?
i'm not sure i fully understand what you are seeing, but it _seems_ like
the physical memory is allocated in order for malloc to store its data
structures. for example, each time you malloc() a block, malloc has to
store the block size somewhere (probably just before that block in
memory). thus, after allocating enough blocks, new pages are required
to store malloc's data. could it be that this is what you're seeing?
the number 512 is especially curious - what size of blocks are you
allocating? assuming there's a need to use 4 bytes to store the size of
each allocated block, and that a memory page contains 4096 byets, then if
each block you allocate is 4 bytes long, you'll see that 512 mallocs will
exactly fill up a memory page
512 * (4 bytes for size + 4 bytes for block) = 4096.
-- guy"For world domination - press 1, or dial 0, and please hold, for the creator." -- nob o. dy
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/