On Monday 20 October 2008 02:38:05 hamsinv wrote:
After a few search I found out that we cannot use std::string. Instead we should try with interprocess::basic_string. Can anyone guide me through this.
The fundamental issue is that objects which allocate memory on the heap cannot be used with shared memory. Consider what happens when you use a construct a string in shared memory. Upon construction which requires storage (such as assigning it an initial value), the string constructor allocates some memory on the heap (not in the shared memory segment), which is visible only in the constructing process. Using the memory in the other processes tries to access those memory locations which results in undefined behavior. In order to overcome this problem, you need to use a shared-memory-aware string, such as interprocess::basic_string. Please read the section named "Limitations When Constructing Objects In Mapped Regions" in the interprocess manual for more information. Regards, Ravi