Jason,
Could you expand a little on your statement
Joel,
The results you posted look pretty good actually. I don't see any leaks as a result of the OpenFeatureClass call. In fact, if you do a search on "OpenFeatureClass" in the document, it returns nothing, which is a good indicator that it isn't responsible for whatever UMDH caught.
Did your test code show the same problem that your production code is showing? If not, then I think that the problem may be on your side. If the test code does show the same problem, but UMDH didn't turn anything up, you may need to look at other sections of code.
You should also try what Kirk suggested. I think he doesn't expect any difference (nor do I), but it never hurts to try.
I'll let you know if I have time to construct an example using my own data that will reproduce the problem. Please keep posting your progress on the board.
Thanks,
Jason
Jason,
I agree, the OpenFeatureClass is not logged in the result. But, I would like be able to explain why the SciTech .NET Memory Profiler displays an increase of the "Unidentified unmanaged heaps" memory when this loop is performed.
In the result.txt file, I see other call stack trace related to ESRI objects, some of them:
Related to Miner & Miner ArcFM:
mmGeoObjects!???+00000000 : 27412D03
mmSystemObjects!DllGetClassObject+0000D4FB
Others:
Geometry!SpatialReferenceEnvironment::CreateESRISpatialReference+00000019
SdeFDB!SdeCursor::SetupGeometry+000000D9
sde!SES_stream_ok+00000B04
GdbCore!ClassHelper::Init+0000002B
I think it is fair to say that, since the scope of the memory marking is only for the "OpenFeatureClass" function, these functions end up being called when doing "OpenFeatureClass". For some reasons, UMDH doesn't seem to be able to trace the function call stack back to "OpenFeatureClass" function...
Thanks again for your help,
Joel
How much is memory usage increasing between iterations? Does it keep increasing each time if you run the workflow multiple times?
There are a number of possibilities. Here are a few off the top of my head:
1) Some of the unmanaged memory could be the JIT-compiled code, which would only show up the first time you execute a method. Each method is compiled and the machine code cached in memory the first time a method is executed. The cached machine code stays in memory (unmanaged memory) until the process is torn down, if I remember correctly.
2) Events may be fired when you open the feature class that cause other code to execute and allocate memory. If it is ArcFM, it will be harder to tell because I'm pretty sure they don't make their symbol files available. If you don't have symbol files, then you'll get something like this: mmGeoObjects!???+00000000 : 27412D03 that can show you the DLL, but not the class or method names. If there is a way to run your tests with ArcFM out of the picture, it should give you some idea as to whether ArcFM is contributing to your problem. If you know where to find ArcFM's symbol files or symbol server, please let me know--I could make use of them, too.
3) UMDH doesn't just show leaks. It shows all the memory that was allocated between marks including things that ought not be released yet. You can limit the marks to only memory that is no longer referenced by using UMDH's -g flag when you mark memory. This may narrow your search some.
You can also try the LeakDiag tool. I don't remember which heaps that UMDH monitors and doesn't monitor. There is a book called Advanced Windows Debugging that explains all of that. Unfortunately, I had to leave the copy I had with my previous employer since they bought it for me. I need to replace that because it is extremely useful in situations like this.
For 1 loop that opens the 21 feature classes, the memory increases of 40 Kb. But it's not constant, it varies between 38 Kb and 47 Kb. And it really keeps increasing steadily at every iteration.
I did a simple test yesterday. To eliminate the COM wrappers from the equation, I did the same small application in Visual Basic 6. Turns out I had the same behavior, the memory won't free even if I set the FeatureClass variable to "Nothing".
I'm currently developing a work-around, I'll try to perform the OpenFeatureClass only once per feature class during the whole 2-3 days process. At this point, I need to prove that calling OpenFeatureClass many times is the culprit in our process crash.
I'll try to spend some time on the points 2) and 3) of your previous post.
Thanks a lot, you provided very helpful advice. I'll give feedback about my work-around.
Joel
I'm currently developing a work-around, I'll try to perform the OpenFeatureClass only once per feature class during the whole 2-3 days process. At this point, I need to prove that calling OpenFeatureClass many times is the culprit in our process crash.
Joel
Good luck with trying to open the featureclass once per run. Thats exactly what i'm doing and after a few runs my process crashes or gives me an "attempted to read or write protected memory" error that we traced down to the FeatureClass.Search() call. Seems to me even between runs the featureclass is being held and some sort of memory buildup causes our crash. If you have better luck please let me know. Jason, from this post, has tried to help us with our problem too which is greatly appreciated.
Gary
Gary,
yes I was suspicious about doing that... in the end, it didn't work. When we use the same FeatureClass instance for the whole process, at some point, the process hangs at the function "FeatureClass.Search". So no luck with this work-around...