How to get memory usage of a program?

C

Carsten Unterberg

Hi all,

is there a way, how I can get the memory usage of a .Net Compact
Framework-program ? I sometimes got a System.OutOfMemoryException during
graphic operations. I work with .Net Compact Framework 2.0/3.5 on Windows Ce
5.0 / Windows Mobile 5.0 / Windows Mobile 6.0.

Regards,

Carsten Unterberg | Test-Framework
http://test-framework.blogspot.com/
 
P

Peter Wucherer

Hello Carsten,

search for :"windows ce test kit"
http://www.microsoft.com/downloadS/...db-dc8b-4503-8dc9-e75f8e8496c1&displaylang=en
1. Application Verifier: Memory leak detection tool
2. CPUMon: CPU monitoring tool
3. Stress: Device and OS stressing tool


Additional:
Maybe follwing code snippet is useful, it gets the memory state of the
device.
You can check the memory state of the complete device at program
startup and then cyclic while the program is running.


#region MEMORY_INFO
public class MemoryInfo
{
public struct MEMORYSTATUS
{
public UInt32 dwLength;
public UInt32 dwMemoryLoad;
public UInt32 dwTotalPhys;
public UInt32 dwAvailPhys;
public UInt32 dwTotalPageFile;
public UInt32 dwAvailPageFile;
public UInt32 dwTotalVirtual;
public UInt32 dwAvailVirtual;
}


#if WindowsCE
[DllImport("CoreDll.dll")]
#else
[DllImport("Kernel32.dll")]
#endif
public static extern void GlobalMemoryStatus
(
ref MEMORYSTATUS lpBuffer
);

public static bool GetMemoryStatus(ref MEMORYSTATUS memStatus)
{
bool result = true;
// Call the native GlobalMemoryStatus method
// with the defined structure.
memStatus.dwLength = 32; // bytes
try
{
GlobalMemoryStatus(ref memStatus);
}
catch
{
result = false;
}
return result;
}
} // public class MemoryInfo
#endregion

Peter
 
C

Carsten Unterberg

Hi Peter,

thanks a lot.

Regards,

Carsten Unterberg | Test-Framework
http://test-framework.blogspot.com/




Peter Wucherer said:
Hello Carsten,

search for :"windows ce test kit"
http://www.microsoft.com/downloadS/...db-dc8b-4503-8dc9-e75f8e8496c1&displaylang=en
1. Application Verifier: Memory leak detection tool
2. CPUMon: CPU monitoring tool
3. Stress: Device and OS stressing tool


Additional:
Maybe follwing code snippet is useful, it gets the memory state of the
device.
You can check the memory state of the complete device at program
startup and then cyclic while the program is running.


#region MEMORY_INFO
public class MemoryInfo
{
public struct MEMORYSTATUS
{
public UInt32 dwLength;
public UInt32 dwMemoryLoad;
public UInt32 dwTotalPhys;
public UInt32 dwAvailPhys;
public UInt32 dwTotalPageFile;
public UInt32 dwAvailPageFile;
public UInt32 dwTotalVirtual;
public UInt32 dwAvailVirtual;
}


#if WindowsCE
[DllImport("CoreDll.dll")]
#else
[DllImport("Kernel32.dll")]
#endif
public static extern void GlobalMemoryStatus
(
ref MEMORYSTATUS lpBuffer
);

public static bool GetMemoryStatus(ref MEMORYSTATUS memStatus)
{
bool result = true;
// Call the native GlobalMemoryStatus method
// with the defined structure.
memStatus.dwLength = 32; // bytes
try
{
GlobalMemoryStatus(ref memStatus);
}
catch
{
result = false;
}
return result;
}
} // public class MemoryInfo
#endregion

Peter


Hi all,

is there a way, how I can get the memory usage of a .Net Compact
Framework-program ? I sometimes got a System.OutOfMemoryException during
graphic operations. I work with .Net Compact Framework 2.0/3.5 on Windows
Ce
5.0 / Windows Mobile 5.0 / Windows Mobile 6.0.

Regards,

Carsten Unterberg | Test-Framework
http://test-framework.blogspot.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top