Hey! OK OK. We gonna be the best again. I can feel it! Quick question, or maybe I should put this in another thread. Yeah, if I can't fix it today I will post code for help. But, how much is the max memory allocated by Windows in Local & Global Allocate? Is it 4 Meg?
Posted on 2007-12-30 11:00:55 by mrgone
Shouldn't Global & Local Alloc only be limited by the memory available?
Posted on 2007-12-30 11:21:29 by JimmyClif

Shouldn't Global & Local Alloc only be limited by the memory available?


I always thought that it was a matter of how much Virtual Memory you have free, as well.

He might be confusing it with at which point you should use GlobalAlloc vs. VirtualAlloc vs. HeapAlloc.
Posted on 2007-12-30 11:24:33 by SpooK
First of all, drop Local/GlobalAlloc and use HeapAlloc, Local/GlobalAlloc are leftovers from 16bit Win3.x, and they end up calling HeapAlloc in the end anyway.

Next, you should be able to handle more or less any reasonable amount with HeapAlloc, but (especially for win9x) the heap was written for lots of smaller allocations. If you're in the multi-megabyte range, you might want to consider VirtualAlloc instead.
Posted on 2007-12-30 12:30:25 by f0dder
Hey! moved it for me.....you guys are on the ball! Sorry, I will try to stick to the subject for now on.

Anyway, I'm sure they allocate by pages. That much I do know. So do they give a 4 Meg page in 32 bit or is it 4K pages? The problem I'm having is wierd and I might not even be looking at the right thing, but when I pull up a file over a certain size, I loose some of my editing features.

I just need a quick & dirty hex file editor. Go ahead and build the attachment if you want. If you load a small file it works fine. Just back space over the data and repunch it in. But when you load a bigger file, it will backspace once & then you cannot insert anything. It won't respond.
Attachments:
Posted on 2007-12-30 12:34:01 by mrgone
Local/Global/HeapAlloc doesn't allocate in pages. Can't remember the granularity, but it's <= 32 bytes. I've successfully HeapAllocated more than 100 megabyte (in a single chunk) on NT systems, but normally I'd use VirtualAlloc (or other methods) for files of that size.

Dunno if windows ever uses large pages for anything, I think it would be limited to things like AGP memory etc. (since I remember some AMD cpu/chipset bugs and windows workaround when using large pages with AGP memory).

Don't have time to look at your code right now, sorry.

Btw: while Local/GlobalAlloc end up using HeapAlloc (at least on NT), they do pass some secret magic flag values. If you insist on using those outdated functions, make sure you specify GPTR or GMEM_FIXED... or use GlobalLock. Otherwise you might be overwriting heap control structures.
Posted on 2007-12-30 12:38:58 by f0dder

Local/Global/HeapAlloc doesn't allocate in pages. Can't remember the granularity, but it's <= 32 bytes. I've successfully HeapAllocated more than 100 megabyte (in a single chunk) on NT systems, but normally I'd use VirtualAlloc (or other methods) for files of that size.

Dunno if windows ever uses large pages for anything, I think it would be limited to things like AGP memory etc. (since I remember some AMD cpu/chipset bugs and windows workaround when using large pages with AGP memory).

Don't have time to look at your code right now, sorry.

Btw: while Local/GlobalAlloc end up using HeapAlloc (at least on NT), they do pass some secret magic flag values. If you insist on using those outdated functions, make sure you specify GPTR or GMEM_FIXED... or use GlobalLock. Otherwise you might be overwriting heap control structures.


Hey OK, I will try Heap Allocate first. Thanks. Sorry I jumped you the other night. Was fighting with wife again & was in a raw mood....Happy New Year  :shock:
Posted on 2007-12-30 12:49:55 by mrgone
No problems man, the internet lacks facial expressions etc., has language barriers, and sometimes we're just plain old stressed-out humans. No hard feelings, hope things are better, and a happy new-year for you too :)

PS: go for VirtualAlloc or file mapping if you want a hex editor, as long as it's in the quick-and-dirty stage (once you want to support huge files, more complex schemes will be needed).
Posted on 2007-12-30 12:52:29 by f0dder
  OK, thanks again. I'll get back  :P
Posted on 2007-12-30 12:57:29 by mrgone