"closed file" errors, crashes and instance tracking warning

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
serio
Posts: 2
Joined: Wed Mar 14, 2012 2:17 am

"closed file" errors, crashes and instance tracking warning

Post by serio » Wed Mar 14, 2012 2:28 am

Hi,

I'm using the 4.0 trial version on a .NET 4 WPF application.

Steps:
* start a profiling session
* attach to process (using Debugging Tools, since selecting Profling API just crashes my app)
** why would my app crash with the Profiling API selection?
* at this point I get a warning "The memory leak investigation guide requirews at least limited instance tracking"
** what does this mean? I selected "collect instance data" in the previous dialog
* take a couple of snapshots
* close my application

At this point the session starts closing automatically and I get prompted to save my session. While saving I then get "Session cannot be saved (or something). Cannot access a closed file." From that point on I can no longer use the session that was in progress (attempting to use the snapshots gives me more "closed file" errors. If I try to open the session that was saved on disk I get "invalid session file". So my profiling session is lost.

Is this a known issue?

Cheers

Andreas Suurkuusk
Posts: 1028
Joined: Wed Mar 02, 2005 7:53 pm

Re: "closed file" errors, crashes and instance tracking warn

Post by Andreas Suurkuusk » Wed Mar 14, 2012 1:09 pm

These issues are not something we have heard of before.

Attaching using the Profiling API is more intrusive than the Debugging Tools attach, since the profiler will be loaded into the profiled process. This will cause some additional memory overhead in the profiled process, and if the process is very close to run out of memory this can cause an out of memory error, which can cause your process to crash. Is your process close to run out of memory when you try to attach the profiler?

For the memory leak guide to work, it needs to be able to identify instances between snapshots. When using Debugging Tools attach, the profiler will not know how an instance is moved in memory between snapshots and thus instances cannot be identified between two snapshots. "Collect instance data" means that you collect additional field values for each instance (in addition to just the references between instances), it is not related to instance tracking.

I have not seen the error "Cannot access a closed file" before. Maybe this is indirectly caused by the session file size limitation in .NET Memory Profiler 4.0. Did you get any other error messages before the "closed file" message? Would it be possible for you to send us the log-file from the profiler so that we can investigate this further? It's named ProfilerClientLog.txt and you can find the log-file in the folder "C:\Users\Andreas\AppData\Local\SciTech\MemProfiler4\Logs".
Best regards,

Andreas Suurkuusk
SciTech Software AB

serio
Posts: 2
Joined: Wed Mar 14, 2012 2:17 am

Re: "closed file" errors, crashes and instance tracking warn

Post by serio » Thu Mar 15, 2012 9:58 am

Hi Andreas. I lost the log since it looks like there is only one for the latest session. I will try and reproduce when I have spare time. Thanks.

Andreas Suurkuusk
Posts: 1028
Joined: Wed Mar 02, 2005 7:53 pm

Re: "closed file" errors, crashes and instance tracking warn

Post by Andreas Suurkuusk » Mon Mar 19, 2012 7:29 am

Thank you for the log-files you sent us. With the help of the logs we were able to locate and fix a bug in the profiler.

The bug was caused by the fact that the profiler failed to collect a snapshot from the profiled process (the second snapshot in your session). When attaching to a process using the Debugging Tools, there's unfortunately a risk that the snapshot is collected while the garbage collector is moving instances in memory. If this happens, the snapshot collection will fail to collect data about the managed instances.

We have fixed the bug that caused the "closed file" error. We have not yet released the fix officially, but it is included in the latest build (v4.0.126), which you can download from http://memprofiler.com/MemProfilerInstaller4_0_126.exe.

To avoid the problem with failed snapshots, we recommend that you use "Profiling API" attach instead, if possible. But apparantly, this is not working well for you either. This is something we would also like to investigate further. To get more information about this problem, would it be possible for you to send us more detailed log files? To create the log-files you need to use the standalone profiler and supply the "/log:<path>" command line argument, e.g. by using the following Run command:

"C:\Program Files\SciTech\NetMemProfiler4\NetMemProfiler.exe" /log:c\MemProfilerLogs

When you try to attach to the process again, this will create a set of log-files in the c:\MemProfilerLogs folder. If you send the log-files to support@scitech.se, we will take a look at them as soon as possible.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests