Am 04.04.22 um 23:56 schrieb Iron Spring Software:
Everyone probably knows this, but FWIW here's an interesting problem
where I ran out of heap on OS/2 for an application that worked for Linux.
An application using DosSubAllocMem likely /never/ works on Linux. ;-)
I think the heap is being checkerboarded with a mix of large and and
small allocations. I pulled out some large allocations (one or more
chunks of 32K) and used DosAllocMem and DosFreeMem for these, and
everything worked. I assume this is because the OS/2 heap is
preallocated while the Linux heap just grows.
No, you simply fragmeted the address space. There are some patterns that
force this. In this case the memory requirement may raise with O(n²).
Normally, I recommend to prefer the C library allocators over using the
kernel funktions. They are not intended to be used heavily.
The glibc allocator performs quite well with millions of allocations and
frees.
If you really want to write your own allocator, this can be a hard work.
And it is always a trade off between speed and fill factor.
AFAIR DosSub... is simply a linked list with not further optimizations.
If you want to deal with this functions anyway you could use different
pools for different object sizes - small, medium, large. And for very
large allocations you could allocate directly from the kernel. However,
keep in mind that the latter might cause the TLB of your CPU to overflow
which can cause a significant performance impact. So I do not recommend
it unless you have really large chunks of e.g. 1MB.
Marcel
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)