| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Memory Blocks snuffed ? |
Quoting Frank Adam to Adam Fitzpatrick: FA>Had to rewrite it to put it through Pacific C, but the idea does not FA>work there, so it seems it's the RTL doing the shuffle not the OS. AF>That's understandable; if you malloc'ed a 2-byte variable (don't ask AF>_why_ you would...) DOS would use 32 bytes. Just a bit inefficient. FA>Wouldn't that be 16 bytes then ? Maybe you meant two 1 byte vars...?? It needs 1 paragraph that you're actually allowed to use and another paragraph to store the information about who owns that block of memory, how big it is, and whether or not there is any more memory after it. DOS keeps a record of what's free and what's been allocated in a linked list of these Memory Control Blocks. Each one contains a flag to specify whether or not it's the last one in the chain, the number of paragraphs in this block, the address of the PSP of the program that owns this block of memory, and (in at least DOS 5.0+, and possibly 4.0) the name of the program. AF>FWIW, a block of memory allocated by DOS has its size stored at AF>(s-1):3, where s is the segment returned in AX by the mov ah,48h; int FA>Yes, that reflects what i've found in Borland, doesn't explain why FA>Pacific didn't come up with the same results though. It might just allocate the whole damn chunk of free memory in one go. It's possible that Borland allocates a new chunk of RAM every time it needs some, and does its own management of those chunks. That's probably a good idea if you're in an environment where other programs are competing for your 640k, but I can't think of many examples of that happening to be honest. It's still a good idea though. AF>21h call. So memory allocated by DOS will have the (char)(ptr-16) as AF>'M' or 'Z' and (short)(ptr-13)<<4 will be the size of the memory block AF>(shifted 4 bits to the left because it's stored as a number of AF>paragraphs, ie 16-byte blocks). FA>What determines the size of a paragraph ? Or is it always 16 ? It's 16 by definition; DOS uses it because the real mode segments are 16 bytes apart (ie 0:0 is 16 bytes below 1:0). ... Newsflash: Multiple personality rapist sentenced to two life terms! --- FMailX 1.02* Origin: Power BBS - +61-2-858-4114 - Files/Games/EchoMail/Internet (3:711/953) SEEN-BY: 50/99 620/243 623/630 711/401 409 410 413 430 808 809 932 934 946 SEEN-BY: 711/953 963 712/515 713/888 714/906 800/1 @PATH: 711/953 410 808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.