Boost logo

Boost Users :

Subject: Re: [Boost-users] [Interprocess] How to prevent collision of mapping addresses with DLL Loading on Windows?
From: Eric J. Holtman (eric_at_[hidden])
Date: 2009-12-14 08:36:51


pheres wrote:
>
> -Allocate the memory range as the first call in main() using
> OS-specific functions like VirtualAlloc()
This is what I do.

It's not 100% reliable (because at some point, you're going to
have to VirtualFree the slice so the shared memory lib
can use it), but it's better than most alternatives.

If *you're* writing the code that uses the shared memory
block, I would *strongly* encourage you to attempt to
re-write it so that you don't need to have it loaded into the
same address location in all processes.

The only reason I researched and use the "first in main"
trick is that I'm using a vendor-supplied library that
really really really wants a certain location. Needless to
say, I've been on their case to fix that, since it's brittle,
at best, and completely unworkable in certain cases
(like, where I'm writing a lib, and using their lib, but I
didn't write "main").


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net