🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #2278

Re: Global memory question

#2278
From: Ton Plooy
Date: Fri, 22 Jan 1993 11:51
33 lines
2185 bytes
In article <1993Jan21.043651.22090@empire.cce.cornell.edu> avinogra@empire.cce.cornell.edu (Alex Vinogradov) writes:
>Hello,
>I have to allocate large number of small memory blocks (for simlicity, let's
>say that it is a huge linked list each node of which is quite small).  The
>problem is in following -- I cannot use local memory for it since it gets
>overflowed pretty fast; the problem with global memory is that I do not
>want to spend 20 bytes for overhead for each of my 20-30 bytes memory blocks
>because I will be using nearly twice as much memory as I really need.  Does
>anyone has any ideas on how should I design my memory management scheme?
>I don't think I am the first one who came up with this question, but none
>of the books in local library mentions that.
>
>The other related to this question I have: what is GetSelectorBas() / 
>SetSelectorBase()?  I did look it up in Microsoft manuals but they ain't
>too informative on this issue.
>

If you have the MS C7 windows libraries, the _fmalloc function implements
it's own subsegment allocation scheme under windows. It's in my opinion much
better to use this function than the GlobalAlloc/GlobalLock functions. If 
you want to implement your own memory allocation functions, you could try 
out the following. Use GlobalAlloc to allocate a block of data, switch DS 
to the DS of this block, call LocalInit(DS, 0, size) and restore DS. On 
subsequent allocations use LocalAlloc on this block (swapping DS). I remember 
reading an article by Andrew Schulman who implemented this, but I'm not sure 
I have al the details right.
The Get/SetSelectorBase functions are used for accessing specific memory 
addresses, GetSelectorBase retrieves a linear address (divide this by 16 
to get a segment address).

Bye,

    Ton
Technical Details
Message-ID: <1993Jan22.115122.17446@microsoft.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!wingnut!tonplooi
References: <1993Jan21.043651.22090@empire.cce.cornell.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!wingnut!tonplooi
From: tonplooi@microsoft.com (Ton Plooy)
Subject: Re: Global memory question
Message-ID: <1993Jan22.115122.17446@microsoft.com>
Date: 22 Jan 93 11:51:22 GMT
Organization: Microsoft Corporation
References: <1993Jan21.043651.22090@empire.cce.cornell.edu>
Lines: 34