Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want my application to restrict user to a predefined space in memory and if user tries to access more than the alloted memory then it should not allow and should display a error message.The applicaion also allocates the memory.So Please help me out what C++ functionality can be used.

Thanks in advance
Posted
Updated 20-Oct-11 3:59am
v2
Comments
Maximilien 20-Oct-11 9:19am    
Why?
Richard MacCutchan 20-Oct-11 13:46pm    
The usual reason.

The user has no control over memory allocation so this is not something you need to be concerned about, unless your application offers some feature that allocates memory on his behalf.
 
Share this answer
 
1. If you write an application, then this application gest it's separate virtual memory space, and there is no way in heaven or hell to influence the memory space of other applications, which in turn get their own virtual memory space from the OS. You'd need to write an OS to control that!

2. If you want to write a library or subsystem, then you can of course provide mechanisms that influence every application that uses this subsystem.

Assuming you mean the latter, you can simply override the global operators ::operator new() and ::operator delete(). If that is what you wish to accomplish, then maybe you should google for set_new_handler, which I've heard is a somewhat safer version (never tried anything like that myself though).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900