Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    195
  • comments
    198
  • views
    104193

Fun with memory

Sign in to follow this  
SiCrane

88 views

Today I experimented with a C++ per class allocator scheme. As I mentioned earlier, I believe memory access to be the weakest point in modern computer architecture, so I spend a lot of time playing with memory.

So today I toyed with a technique that subdivides the address space into one megabyte chunks. Each one of these chunks is used to allocate objects for a single polymorphic class. However, the classes aren't implemented with traditional vtable techniques. Instead they have an implicit vptr that points to the beginning of the one megabyte chunk that they live in. If enough objects are created that multiple chunks are needed for a given class then that means that multiple copies of the vtable would exist.

It's not a new idea; I think I first read about it in D&E a number of years ago. However, today was the first time I looked at it from the angle of making it the default allocation scheme used by the compiler. At that point I got stopped cold. Multiple inheritance would be a mess, but I think there's a way around that. It was placement new and stack allocation that ended things. Basically the only way I could think of handling them would have meant restoring the vptr member which renders the whole idea more or less pointless.

Oh well, tommorrow I think I'll start work in my code library to make the manual implementation less painful.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!