Marcel Mueller <
news.5...@spamgourmet.org> wrote:
> 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. ;-)
Iron Spring PL/I started out as an OS/2 application. It ‘s pure PL/I, and
doesn’t use an C code, so I had to port an allocator for the Linux version.
I could probably move it to OS/2 if there are no other options.
>
>> 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²).
Same thing in different words. This goes back to the beginning of the
compiler many years ago. I had no idea how much memory would be required
for the parse table of a large program, so QandD was a a linked list of 32K
blocks. There are better ways to handle this. The compiler works fine, but
I reused the parser logic for the preprocessor, so there’s a different
pattern of memory use that breaks the system.
>
> 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.
>
See above. I don’t want any dependencies on the C library.
> 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.
Thanks. I tried looking in the debug handbooks, etc., but couldn’t find any
detail on DosSub.. I miss having source to look at. I guess I never
stressed it before. As I said, it was QandD that always just worked, but
it’s very inefficient and could probably be improved with minimal effort.
>
>
> Marcel
>
--
Pete