MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Calling kernel.dll from

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108580] Re: Calling kernel.dll from
  • From: Todd Gayley <tgayley at wolfram.com>
  • Date: Wed, 24 Mar 2010 04:42:12 -0500 (EST)

At 02:46 AM 3/20/2010, =C0=EB=E5=EA=F1=E5=E9 =CF=EE=EF=EA=EE=E2 wrote:
>Todd ,
>
>Many thanks for the detailed response. Both methods are shown by you, very
>interesting.
>
>And thanks for sending a separate copy of the message directly to me:
>message appeared in the newsgroup is damaged, and part of the code from it
>does not work even after the correction of obvious damage.
>
>I have a question on the first method. As I understand, the function
>mo["FreePhysicalMemory"]
>will return the value corresponding to the time of creation of the first
>NETObject ('query'). Thus, it is not suitable for periodic calls on a
>regular basis.
>How can I get the actual value corresponding to the time of the call? Or how
>can I force updating of the values?


Alexey,

Just re-do the entire call when you need the
current values. Here is the code packaged as a function:

GetMemoryData[] :==
    NETBlock[
       Module[{query, mo},
          query ==
NETNew["System.Management.ManagementObjectSearcher",
"SELECT * FROM Win32_OperatingSystem"];
          mo == First[NETObjectToExpression[query@Get[]]];
          (# -> mo[#])& /@
{"TotalVisibleMemorySize", "FreePhysicalMemory", "TotalVirtualMemorySize"}
       ]
    ]


In[10]:== GetMemoryData[]

Out[10]== {TotalVisibleMemorySize -> 3143336,
FreePhysicalMemory -> 1124652, TotalVirtualMemorySize -> 4444440}



Todd Gayley
Wolfram Research


  • Prev by Date: Solving differential equations in Mathematica 7.0
  • Next by Date: Probability Histogram Problems
  • Previous by thread: Re: Solving differential equations in Mathematica 7.0
  • Next by thread: Probability Histogram Problems