Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Let me rephrase the question:-
Say process A and B.

1. 'A' creates named shared memory (CreateFileMapping)
2. 'B' opens shared memory (OpenFileMapping)
3. 'A' terminates abnormally. Or lets say it just exits properly.

Consider situations in which Process A can "NOT" signal process B that it is terminating.

-->Does the memory persist? If so, for how long?
-->What does Process B expect to face here.

-----------------------------------
Hello,
I may be repeating a question or should have known but searching through various blogs hasn't yet made me understand.

I am creating an IPC application where one process creates a shared memory and the other process accesses it.
Both processes are going to read/write into it. Threads and synchronization is being taken care.
The question I have is that what happens to the memory when the creator crashes abnormally.
1. What do I expect when the creator crashes?
2. Will the accessing application face a "bad pointer"/ access violation?
3. Will it be accessible forever or go bad at some later point of time?

I in fact want the accessing application (which opens view to file) to get to know immediately so that it can do the business logic I need to do at the upper layer.

Please let me know or point me to some source of information.

Thanks!!
Posted
Updated 2-Oct-15 22:28pm
v2
Comments
Sergey Alexandrovich Kryukov 2-Oct-15 16:48pm    
It's hard to say anything because you provide no useful information on the "crash". I have no idea what kind of crash you are talking about.
—SA
_SurajP 3-Oct-15 4:28am    
Crash isn't the question at all. Let me rephrase the question:-
Say process A and B.

1. 'A' creates named shared memory (CreateFileMapping)
2. 'B' opens shared memory (OpenFileMapping)
3. 'A' terminates abnormally. Or lets say it just exits properly.

Consider situations in which Process A can "NOT" signal process B that it is terminating.

-->Does the memory persist? If so, for how long?
-->What does Process B expect to face here.
Sergey Alexandrovich Kryukov 3-Oct-15 6:49am    
Sorry, I was too fast. This is actually a good question (my 5). I think the shared memory object will leave while at least one process holds is by having non-closed handle to it, so nothing bad will happen to B if A terminates, no matter gracefully of not. Semantically speaking, your functionality can be destroyed, but, technically, nothing bad happens to B. I still have to confirm it more accurately...
—SA

1 solution

Quote:
The question I have is that what happens to the memory when the creator crashes abnormally.

Whatever the reason, consequences can't be good.
The best is to not crash at all.
Use technic like try/catch to guard risky parts of your code.
Remove as much bugs as possible, the debugger will help catch bugs.
 
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