News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GlobalAlloc

Started by Jimg, December 16, 2005, 03:15:52 PM

Previous topic - Next topic

Human

well i think one simple explenation will help, for memorymapped file windows doesnt read whole file into memory, just swaps in and out 4kb pages, so in that mode, it better fits l1,l2 cache, also on second run same test will be faster because windows already has that file in file cache. also for better test results we should copy whole mapped memory somewhere, due maybe writeback cache technology we read memory from cache but its in cache and not in memory yet because l1,l2 cache have not wrote that into memory where we have mapped file, but its just what i assume

QvasiModo

GlobalAlloc and VirtualAlloc shouldn't experience much of a difference for big alloc sizes, since the Windows heap implementation itself calls VirtualAlloc in such cases. I think the limit for determining when to call VirtualAlloc and when to use the heap is around 20k.

hutch--

One of our members a while ago did some benchmarking on a range of memory allocation techniques and different strategies seem to have different advantages. HeapAlloc() was the fastest on repeated small allocations where the old GlobalAlloc() with fixed memory was very fast on big allocations., OLE string memory has got slower and VirtualAlloc seems to be somewhere in the middle. There is of course a very wide range of overlap with most of these methods so it tends to be what is the most convenient to use that is the most use.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

Quote from: QvasiModo on December 19, 2005, 04:02:03 PM
GlobalAlloc and VirtualAlloc shouldn't experience much of a difference for big alloc sizes

I assume you're responding to Human, since nobody else has mentioned VirtualAlloc.

By paging, he was not suggesting that the entire file is copied into virtual memory (as this is what would happen with the GlobalAlloc method). Instead, only 4kb of the file is in memory at any one time. If another part is wanted, then the current 4kb is disposed of and the new 4kb is read. This should be much quicker for random-starting-point sequential access because it will only read/copy 8kb.

Copying the entire file into memory (and then possibly back to the disk :eek) is the alternative and for big files this will obviously take time.

DC

958869 bytes
10571368 cycles
12050214 cycles
does this mean I need a new computer?
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net