Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "MEMORYSTATUS" in [All]

kernel32

.
Summary
.

static extern bool GlobalMemoryStatusEx( [In,Out] MEMORYSTATUSEX lpBuffer); //Used to use ref with comment below

.

                                    //comment: most probably caused by MEMORYSTATUSEX being declared as a class

.

    // Also See Alternate Version Of [MEMORYSTATUSEX] Defined As A Structure.

.

    [DllImport( "kernel32.dll", CharSet = CharSet.Auto, EntryPoint = "GlobalMemoryStatusEx", SetLastError = true )]

.

    static extern bool _GlobalMemoryStatusEx( ref MEMORYSTATUSEX lpBuffer );

.

Private Declare Function GlobalMemoryStatusEx Lib "kernel32" Alias "GlobalMemoryStatusEx" ( _

.

     <[In](), Out()>ByVal lpBuffer As MEMORYSTATUSEX _

.

MEMORYSTATUSEX

.

The CLR offers us no way to tell if memory is getting tight. Many think that this API provides the best solution. This is mentioned by Jeffrey Richter in his book 'CLR via C#' ISBN: 0-7356-2163-2. It is useful in determining if your system is under excessive memory load by looking at the dwMemoryLoad member of the MEMORYSTATUSEX structure. If this value is > 80 (per Mr. Richter in his discussion of Garbage Collection), it is an indication that you might want to consider converting some strong references into weak references. Remember that a weakreference type will be collected when Generation 0 is full, so it is not a good technique for caching (as many seem to think).

.

         private     MEMORYSTATUSEX msex;

.

            msex = new MEMORYSTATUSEX();

.

            if (GlobalMemoryStatusEx(msex)) {

.

                 throw new Exception("Unable to initalize the GlobalMemoryStatusEx API");

.

        private class MEMORYSTATUSEX

.

                  public MEMORYSTATUSEX()

.

                      this.dwLength = (uint) Marshal.SizeOf(typeof( MEMORYSTATUSEX ));

.

         static extern bool GlobalMemoryStatusEx( [In, Out] MEMORYSTATUSEX lpBuffer);

.

    public static bool GlobalMemoryStatus( ref MEMORYSTATUSEX msex )

.

        msex.dwLength = (uint)Marshal.SizeOf( typeof( MEMORYSTATUSEX ) );

.

        return( _GlobalMemoryStatusEx( ref msex ) );

.
Documentation
[GlobalMemoryStatusEx] on MSDN
.
Summary
.

static extern bool GlobalMemoryStatusEx( [In,Out] MEMORYSTATUSEX lpBuffer); //Used to use ref with comment below

.

                                    //comment: most probably caused by MEMORYSTATUSEX being declared as a class

.

    // Also See Alternate Version Of [MEMORYSTATUSEX] Structure With

.

    [DllImport( "kernel32.dll", CharSet = CharSet.Auto, EntryPoint = "GlobalMemoryStatusEx", SetLastError = true )]

.

    static extern bool _GlobalMemoryStatusEx( ref MEMORYSTATUSEX lpBuffer );

.

Private Declare Function GlobalMemoryStatusEx Lib "kernel32" Alias "GlobalMemoryStatusEx" ( _

.

     <[In](), Out()>ByVal lpBuffer As MEMORYSTATUSEX _

.

MEMORYSTATUSEX

.

The CLR offers us no way to tell if memory is getting tight. Many think that this API provides the best solution. This is mentioned by Jeffrey Richter in his book 'CLR via C#' ISBN: 0-7356-2163-2. It is useful in determining if your system is under excessive memory load by looking at the dwMemoryLoad member of the MEMORYSTATUSEX structure. If this value is > 80 (per Mr. Richter in his discussion of Garbage Collection), it is an indication that you might want to consider converting some strong references into weak references. Remember that a weakreference type will be collected when Generation 0 is full, so it is not a good technique for caching (as many seem to think).

.

         private     MEMORYSTATUSEX msex;

.

            msex = new MEMORYSTATUSEX();

.

            if (GlobalMemoryStatusEx(msex)) {

.

                 throw new Exception("Unable to initalize the GlobalMemoryStatusEx API");

.

        private class MEMORYSTATUSEX

.

                  public MEMORYSTATUSEX()

.

                      this.dwLength = (uint) Marshal.SizeOf(typeof( MEMORYSTATUSEX ));

.

         static extern bool GlobalMemoryStatusEx( [In, Out] MEMORYSTATUSEX lpBuffer);

.

    public static bool GlobalMemoryStatus( ref MEMORYSTATUSEX msex )

.

        msex.dwLength = (uint)Marshal.SizeOf( typeof( MEMORYSTATUSEX ) );

.

        return( _GlobalMemoryStatusEx( ref msex ) );

.
Documentation
[GlobalMemoryStatusEx] on MSDN

Structures

.
Summary
.

The CLR offer us no way to tell us that memory is getting tight. Many think this API provides the best solution. This is mentioned by Jeffrey Richter in his book 'CLR via C#' ISBN: 0-7356-2163-2. It is useful in determining if your system is under excessive memory load by looking at the dwMemoryLoad member of the MEMORYSTATUSEX structure. If this value is > 80 (per Mr. Richter in his discussion of Garbage Collection), it is an indication that you might want to consider converting some strong references into weak references. Remember that a weakreference type will be collected when Generation 0 is full, so it is not a good technique for caching (as many seem to think).

.

    public class MEMORYSTATUSEX

.

        /// Size of the structure, in bytes. You must set this member before calling GlobalMemoryStatusEx.

.

        /// Initializes a new instance of the <see cref="T:MEMORYSTATUSEX"/> class.

.

        public MEMORYSTATUSEX()

.

        this.dwLength = (uint)Marshal.SizeOf(typeof(NativeMethods.MEMORYSTATUSEX));

.

    /// memory, including extended memory. The GlobalMemoryStatusEx function stores

.

    /// <remarks>MEMORYSTATUSEX reflects the state of memory at the time of the call. It also

.

    public struct MEMORYSTATUSEX

.

        /// calling GlobalMemoryStatusEx.</summary>

.

    Public Class MEMORYSTATUSEX

.

        ''' Initializes a new instance of the <see cref="T:MEMORYSTATUSEX" /> class.

.

        Me.dwLength = CType(Marshal.SizeOf(GetType(MEMORYSTATUSEX)), UInt32)

.

        ''' Size of the structure, in bytes. You must set this member before calling GlobalMemoryStatusEx.

.
See
.
Documentation
[MEMORYSTATUSEX] on MSDN
.
Summary
.

The CLR offer us no way to tell us that memory is getting tight. Many think this API provides the best solution. This is mentioned by Jeffrey Richter in his book 'CLR via C#' ISBN: 0-7356-2163-2. It is useful in determining if your system is under excessive memory load by looking at the dwMemoryLoad member of the MEMORYSTATUSEX structure. If this value is > 80 (per Mr. Richter in his discussion of Garbage Collection), it is an indication that you might want to consider converting some strong references into weak references. Remember that a weakreference type will be collected when Generation 0 is full, so it is not a good technique for caching (as many seem to think).

.

    public class MEMORYSTATUSEX

.

        /// Size of the structure, in bytes. You must set this member before calling GlobalMemoryStatusEx.

.

        /// Initializes a new instance of the <see cref="T:MEMORYSTATUSEX"/> class.

.

        public MEMORYSTATUSEX()

.

        this.dwLength = (uint)Marshal.SizeOf(typeof(NativeMethods.MEMORYSTATUSEX));

.

    Public Class MEMORYSTATUSEX

.

        ''' Initializes a new instance of the <see cref="T:MEMORYSTATUSEX" /> class.

.

        Me.dwLength = CType(Marshal.SizeOf(GetType(MEMORYSTATUSEX)), UInt32)

.

        ''' Size of the structure, in bytes. You must set this member before calling GlobalMemoryStatusEx.

.
See
.
Documentation
[MEMORYSTATUSEX] on MSDN

coredll

.

static extern void GlobalMemoryStatus(ref MEMORYSTATUS lpBuffer);

.

Public Declare Function GlobalMemoryStatus Lib "CoreDll.Dll" _

.

    (ByRef ms As MEMORYSTATUS) As Integer

.

MEMORYSTATUS

.
Documentation
[GlobalMemoryStatus] on MSDN
.

[DllImport("coredll", EntryPoint="GlobalMemoryStatus", SetLastError=false)]

.

internal static extern void GlobalMemoryStatusCE(out MemoryStatus msce);

.

<DllImport("coredll.dll")> Private Shared Function GlobalMemoryStatus(ByRef ms As MEMORYSTATUS) As Int32

.

vb Memorystatus structure

.

Public Structure MEMORYSTATUS

.

C# MemoryStatus structure:

.

internal struct MemoryStatus {

.

    Public Shared Function GetMemory() As MEMORYSTATUS

.

    Dim ms As MEMORYSTATUS

.

    GlobalMemoryStatus(ms)

.
Documentation
[GlobalMemoryStatus] on MSDN

 
Access PInvoke.net directly from VS: