Tech Support > Microsoft Windows > Development Resources > Memory allocation strategy
Memory allocation strategy
Posted by Bob Masta on August 4th, 2003


I need to write a small utility to process some text
files. The files could be over 1 MByte in size.

In the bad ol' DOS days, I would allocate input
and output buffers of 64K each (16-bit seg limit)
and keep track of when to refill and flush as I
worked through the file. Essentially, I was doing
manual paging to disk.

Do I still need to do this in Win32?
Does Windows built-in paging mean that I
Can just allocate huge buffers, big enough to
hold the entire input and output files, and let
Windows worry about paging them to/from disk as needed?
Or will the allocation fail above some limit?
(Determined by Windows own RAM usage,
or ???)

Thanks!





Bob Masta
dqatechATdaqartaDOTcom

D A Q A R T A
Data AcQuisition And Real-Time Analysis
Shareware from Interstellar Research
www.daqarta.com

Posted by Alex Blekhman on August 4th, 2003


"Bob Masta" <no_spam@aol.com> wrote in message
news:3f2e4ace.729459@news.itd.umich.edu...
Under Win32 you can do without allocation at all. Just create memory
mapping for desired file and access it as regular memory buffer. System
will do the rest.

HTH
Alex



Posted by Tim Robinson on August 4th, 2003


The other guys are right about memory-mapped files. Just one more point --
you do have a size limited. Admittedly it's not as small as 64KB, but you
are limited to the largest contiguous chunk within your address space.
Usually you'll have lots of free address space where a memory-mapped file
could be fitted, but if you've alloated and freed a lot of memory, there's a
good chance your address space will be quite fragmented.

Anyway, shouldn't be a problem until you reach into the hundreds of
megabytes.

--
Tim Robinson (MVP, Windows SDK)
http://www.themobius.co.uk/

"Bob Masta" <no_spam@aol.com> wrote in message
news:3f2e4ace.729459@news.itd.umich.edu...


Posted by Stephen Kellett on August 4th, 2003


In message <bgm8qe$pkdj4$1@ID-103400.news.uni-berlin.de>, Tim Robinson
<tim.at.gaat.freeserve.co.uk@invalid.com> writes
If you want to see a visualization of the "holes" in the memory space,
grab VM Validator (its free) from http://www.softwareverify.com on the
downloads page.
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk
RSI Information: http://www.objmedia.demon.co.uk/rsi.html


Similar Posts