* Write allocated mallocs
@ 2002-03-13 0:41 Ben Israel
2002-03-13 7:11 ` guy keren
0 siblings, 1 reply; 2+ messages in thread
From: Ben Israel @ 2002-03-13 0:41 UTC (permalink / raw)
To: linux-kernel
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?
Ben Israel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Write allocated mallocs
2002-03-13 0:41 Write allocated mallocs Ben Israel
@ 2002-03-13 7:11 ` guy keren
0 siblings, 0 replies; 2+ messages in thread
From: guy keren @ 2002-03-13 7:11 UTC (permalink / raw)
To: Ben Israel; +Cc: linux-kernel
On Tue, 12 Mar 2002, Ben Israel wrote:
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-03-13 7:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-13 0:41 Write allocated mallocs Ben Israel
2002-03-13 7:11 ` guy keren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®