0

is it possible to share a custom object model in memory space across .NET applications without duplicating working memory in each of functioning application's memory scope?

M4V3R1CK
  • 765
  • 3
  • 9
  • 22
  • possible duplicate of [Sharing data between AppDomains](http://stackoverflow.com/questions/2206961/sharing-data-between-appdomains) – Tim Schmelter Aug 28 '12 at 20:57
  • I am not quite sure but [Shared memory in .Net ][1] and [Shared memory between 2 process][2] threads might help. [1]: http://stackoverflow.com/questions/439787/how-to-implement-shared-memory-in-net [2]: http://stackoverflow.com/questions/2004790/shared-memory-between-2-processes-applications – VRK Aug 28 '12 at 21:02
  • Yeap, MMF seems to be the only option. – Marcelo De Zen Aug 28 '12 at 22:41

1 Answers1

0

It's not impossible, but very hard.

It's possible to run your programs under a private version of CLR profiler. The profiler DLL injected into the process know exact where ohjects are at anytime. Then difference processes can share data using native code.

Feng Yuan
  • 709
  • 5
  • 4
  • This does not seems plausible. 1) Profiler is tool, it does not manage memory 2) The CLR knows exact where objects are, but this does not mean you can access those objects, because CLR can move they around and your pointer will become invalid. – Marcelo De Zen Aug 28 '12 at 22:39
  • Yes, CLR profiler has two binary: clrprofiler.exe and profilerobj.dll. The profilerobj.dll gets injected into managed process and gets notifications from CLR. So it can know 'everything'. – Feng Yuan Aug 28 '12 at 22:57
  • Still doesn't make sense. How could you use this to share memory across processes? What if GC moves the objects around or collect them? How could the other application possibly know about this? Again, the CLR profiler is a profiler, a tool, intended to be used to solve performance related problems. There is nothing to do with memory management and for sure is not designed to be used in production unless you need to *profile* the app to collect data. – Marcelo De Zen Aug 28 '12 at 23:14
  • When GC moves object around, it notifices profiler first. So profilerobj.dll knows addresses of every managed objects. – Feng Yuan Aug 28 '12 at 23:52
  • CLRProfiler needs admin right to use. Here is the doc for ICorProfilerCallback::MovedReferences http://msdn.microsoft.com/en-us/library/ms231919 – Feng Yuan Aug 29 '12 at 09:07
  • Noop, still don't make sense. That is just a snapshot, the gc doesn't stop while calling the callback. I think you are missing some primitives and avoiding to think about your answer. Not constructive. I'll stop here. – Marcelo De Zen Aug 29 '12 at 10:09