According to Orlando Llanes:
I'm curious about something with objects as it will affect the game lib.
What I need to know is how objects work at run-time.
Each instance of each object has an implicit "vmt" field which contains a pointer to the "virtual method table" where the addresses of all virtual methods are stored. GPC produces inline code to initialize the vmt immediately before a constructor is called. (BP does the assignment inside the constructor instead.) When a virtual method is called, the program dereferences the vmt field, and so on.
Is there a way to create an object so that it will be loaded only if allocated with "New"? In other words, is there a way to keep the code for the object on disk until it's needed, and removed form memory when not?
Write a constructor that fetches all needed data from the file when the object is `New'ed; if you want to keep the stuff in the file current, write a destructor that writes everything back to disk when the object is `Dispose'd. (* BTW, this has nothing to do with the internals how objects work at run-time. ;*)
You are obviously writing a memory manager to keep the amount of RAM your program uses small and to use the disk instead. On UNIX-like platforms you don't need to do this because the operating system does it for you. Just allocate as many MegaBytes as you need; if this exceeds your physical RAM the operating system swaps out the unneeded parts automatically and restores them when they are needed again. Your application does not even notice this.
Have fun,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201] maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]