Win32 memory

Windows specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

Hi,

A question for the Windows gurus out there.

What is the preferred method of allocating memory under Windows?

I wrote some code that uses GlobalAlloc, but I have been reading the Win32 reference I have and noticed that it says the GlobalXXX functions are provided for backwards compatibility with Windows3.x.

I'd like to be able to use functions that are like the GlobalAlloc and PureBasic ones (you tell it how much memory you want and you either get it or you don't), but without the need to use bank numbers. The Win32 virtual memory functions seem to be only half a memory management system (as I'm only going to be allocating small memory sizes at one time so I would something to manage the memory within the virtual pages or it would be very wasteful). The heap functions sound OK, but I don't know if there any any limitations (other than they might become fragmented).

I've looked around the web for stuff about Win32 memory management, hoping to find some sane examples, but I could not find any.

So (just in case you forgot or fell asleep through all that :wink: the questions are now:

What is the preferred method of allocating memory under Windows, are there any good examples, are there any DLLs for memory management?

Thanks.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)