Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
Oct 2, 1998

Process Local Storage

Question:
Is there a way to get memory allocated that is global to the current process? Thread local storage won't do the trick because you need a global handle to access it. My problem is that I need some memory that any thread in the process can access, but that can't be accessed by other processes/instances of the same application. The memory needs to be accessed from the main program and from several DLLs.

Answer:
If you are working with 32-bit Windows, you can simply allocate global memory and it should be available to all threads running within that process. In addition, it would not be available to other processes because 32-bit Windows runs each process in its own address space.

If you are going directly to the API, newer applications can manage memory using the HeapAlloc, HeapReAlloc, HeapFree, and HeapSize functions. These are all specific to the running process.

The GetProcessHeap function obtains a handle to the heap of the calling process.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date