We've been experiencing problems with the way 3rd-party component thread code is being handled in Delphi XE. I say 3rd-party because our core application does not implement any multi-thread code on its own. What i've determined is that strange memory corruptions occur if I use SimpleShareMem (we have several dll's that share string data with the main app), but these errors disappear if I install the FastMM4 unit. And by strange I mean the errors are rarely the same twice in a row, though they are in the same general area. I initially installed FastMM4 to try and determine the cause of the errors, but in fact they simply do not occur when it is installed. I've set up conditionals in my option set that allow me to flip all modules in the project group back and forth between SimpleShareMem and FastMM, and can demonstrate my conclusion pretty readily.
My immediate example is TRichView. I've figured out that when I have the hunspell spellchecker engaged, I can produce an error in or near the PaintBuffered/PaintTo procedure by simultaneously pasting and click-scrolling upwards quite a few times (it differs as to how many times I need to do this to produce the error). Sometimes it is an external exception that resolves to a surfaced exception, other times I reach stack overflow within exception handling code.
Another example i've encountered is the AnyDAC (DA-SOFT) remote/file monitoring system, also running in a seperate thread, that will not function with SimpleShareMem but works fine with FastMM4.
Based on these experiences, i'm compelled to build using the FastMM4 unit for the production builds, as weird as that might seem even to me. Of course, I always suspect my own code first, so i'm wondering if there is something that I could be doing to exacerbate the problem, though FastMM4 doesn't show the main app as having any stack corruptions, etc.
So, my question is, can anyone think of a reason why FastMM4 would work better for multi-threaded operations than whatever version of FastMM that Delphi XE is using?
Update: I wanted to add that i've now done some testing using the older Sharemem/borlndmm.dll concept and that too works just fine.
Update 2: Thank you for the suggestions. I have been trying to find the heisenbug that is causing my problem, with very little success. I do have an additional observation.
If I modify the main app so that it doesn't load the DLL needing ShareMem, I have no problems with either AnyDAC logging or TRichView, regardless of the memory manager I use. The very act of loading that DLL (which launches the initial instance of FastMM and is shared with the main app) will cause the problem even if I make no calls into that dll. The next thing i'm going to do is modify the main app to enable a dynamic load of that dll (and thus force the memory manager install into the main app) and see if that makes a difference.
Update 3: Dynamically loading the dll has the same effect as not loading it...everything works.