Memory usage question

J

Jenea Ciur

Hi !
If I will make

char* pHugeMemory = (char*)malloc( huge_number_of_bytes );

in some place of my program, and after some time my program will jump
to other processing place, that won't reference pHugeMemory location,
then if physical memory storage is full, I suppose Windows, will
discard lots of RAM memory pages to some swap place on my Hard Disk
drive... right ?
Now, if after some time I will refernce pHugeMemory, for reading, for
example, then Windows will discard ( may be ) , something else and for
sure will load all pHugeMemory back to physical memory.
Now Question:

Is there some win32 functions that could make me aware when my program
references pHugeMemory memory location ? I mean to make me aware of
when someone tries to read or write that location ?

More exactly :
that memory allocation is one XXX.DLL ( that is : allocated in
function exported from DLL ) that is shared among more then one
process.
I would like to make aware all other processes ( that have loaded
XXX.DLL ) when one process tries to read/write any located memory (
pHugeMemory ) from a function exported from that XXX.DLL.

Any suggenstions are welcome.
Thank you in advance.

PS:
I that don't make sense I will more accurate next time ;)
 
B

Bruno van Dooren [MVP VC++]

More exactly :
that memory allocation is one XXX.DLL ( that is : allocated in
function exported from DLL ) that is shared among more then one
process.

Unless that memory is shared memory (which it isn't, from your description)
each process has its own memory allocation in its own memory context.

The fact that you allocate it inside the dll does not make it shared memory.
See here for an explanation of how to use shared memory on windows.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/file_mapping.asp

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top