Re: How much memory
- From: George Peter Staplin <georgeps@xxxxxxxxxxxx>
- Date: Sun, 26 Apr 2009 13:42:09 -0600
Nigel wrote:
Is it, for some reason, a bad idea to allocate upwards of 1 megabyte
on the heap via malloc? The reason I ask is that it seems fine, but I
haven't seen people do it before. Perhaps malloc, free and realloc are
inefficient for this much memory?
I routinely do this, sometimes with allocations up to a GiB or more. If
you're working with DOS it would be different, because of the restrictions
imposed there when using a legacy mode.
Consider that if you have an offscreen matrix of pixels for an image that
fills the screen you would need this much memory with a 1280x1024 display:
% set size [expr {1280 * 1024 * 4}]
5242880
Now let's see how much that is in terms of MiB:
% expr {$size / 1024.0 / 1024.0}
5.0
That's 5 megabytes or if you're a disk manufacturer 5 mebibytes. Some
systems might optimize that to be stored in VRAM (video RAM). Windows for
instance creates VRAM-backed bitmaps from what I understand in some cases
with certain Win32 calls.
-George
.
- References:
- How much memory
- From: Nigel
- How much memory
- Prev by Date: Re: How much memory
- Next by Date: Re: How much memory
- Previous by thread: Re: How much memory
- Next by thread: doing things with binary trees
- Index(es):
Relevant Pages
|