#Large Model
2 messages in this thread
I have been working through Charles Petzold's book 'Programming Windows'.
Could anyone help with a couple of misunderstandings on my part, please.
On page 285 of Petzold's book for win v3.1, he talks about why using large
model is a bad idea, you use an example of a static pointer : "if the pointer
references a movable data segment, the value of the pointer must be adjusted
when windows moves the data segment it references".
I had thought that if the segment portion of the pointer is simply a segment
selector whose value can remain the same by changing its entry in the selector
table; hence there would be no problem in using large model – at least as far
as this example is concerned.
I appreciate that I'm misunderstanding this somewhere, but where?
Also, on the subject of far data & large model, do you know whether using
Microsofts MFC library can I create classes derived from their CObject such
that they use memory from the global heap rather than the local heap?
I want to create _lots_ of objects which are soon going to need more than 64k.
How do I do it?
Regards & Thanks in advance,
Michael Lewis, Totem Systems Ltd
Hi,
Well Michael, I have good news for you on both counts.
Petzold's comment was probably made in the first edition and not corrected in
subsequent editions. As you mentioned, Windows maintains a selector table and
when segments move, your pointers will remain valid.
As far as the local heap goes, you would be a complete mug not to use the large
model with MFC. The local allocator now does sub-segment allocation on the
global heap. This means each heap allocation (object in your case) must be <64K
but you can have as many as will fit in global memory. Hooray!
Hope this helps,
Jim