Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-19-2005, 01:16 PM
Junior Member
 
Join Date: Jan 2005
Posts: 7
Default memory use of my application

is there a way to retrieve the amount of memory of my ram which my swfkit application uses?
any method that says: currently using 17mb ram, or something like that?
Reply With Quote
  #2 (permalink)  
Old 01-19-2005, 02:31 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:memory use of my application

Use the windows api "GetProcessMemoryInfo", but it can only work on windows nt/2000/xp.
Reply With Quote
  #3 (permalink)  
Old 01-19-2005, 02:39 PM
Junior Member
 
Join Date: Jan 2005
Posts: 7
Default Re:memory use of my application

yes i found this method in the msdn. unfortunately i didn't find examples or codesnippets in this forum, showing me, how to use the "GetProcessMemoryInfo" method.
i miss some "Dll.registerFunction" examples or tutorials ;-)
Reply With Quote
  #4 (permalink)  
Old 01-19-2005, 02:42 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:memory use of my application

We will make a sample for you tomorrow.
Reply With Quote
  #5 (permalink)  
Old 01-19-2005, 02:43 PM
Junior Member
 
Join Date: Jan 2005
Posts: 7
Default Re:memory use of my application

thanks, i'm very excited
Reply With Quote
  #6 (permalink)  
Old 01-20-2005, 02:45 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:memory use of my application

Code:
/*
typedef struct _PROCESS_MEMORY_COUNTERS {
    DWORD cb;
    DWORD PageFaultCount;
    SIZE_T PeakWorkingSetSize;
    SIZE_T WorkingSetSize;
    SIZE_T QuotaPeakPagedPoolUsage;
    SIZE_T QuotaPagedPoolUsage;
    SIZE_T QuotaPeakNonPagedPoolUsage;
    SIZE_T QuotaNonPagedPoolUsage;
    SIZE_T PagefileUsage;
    SIZE_T PeakPagefileUsage;
} PROCESS_MEMORY_COUNTERS;

sizeof(PROCESS_MEMORY_COUNTERS) = 40
*/

// define a customized pointer type, size is 40
var ProcessMemoryCountersType = new DllParam(40, 1);

/*
BOOL GetProcessMemoryInfo(
  HANDLE Process,                          // handle to process
  PPROCESS_MEMORY_COUNTERS ppsmemCounters, // buffer
  DWORD cb                                 // size of buffer
);
*/

// register the  GetProcessMemoryInfo function
var success = Dll.registerFunction("Psapi.dll", 
"GetProcessMemoryInfo", "getPMemInfo", "stdcall",
"long", "long", ProcessMemoryCountersType, "long");

Dll.registerFunction("kernel32.dll", "GetCurrentProcess", 
"getCurrentProcess", "cdecl", "long");

// handle the PROCESS_MEMORY_COUNTERS structur
function MemInfo()
{
var i;
this.value = new StringStream;

// fill the value
this.value.write(40);
for (i = 4; i < 40; i++) this.value.put(0);

function PageFaultCount()
{
this.value.getPos = 4;
return this.value.getLong();
}

function PeakWorkingSetSize()
{
this.value.getPos = 8;
return this.value.getLong();
}

function WorkingSetSize()
{
this.value.getPos = 12;
return this.value.getLong();
}

function QuotaPeakPagedPoolUsage()
{
this.value.getPos = 16;
return this.value.getLong();
}

function QuotaPagedPoolUsage()
{
this.value.getPos = 20;
return this.value.getLong();
}

function QuotaPeakNonPagedPoolUsage()
{
this.value.getPos = 24;
return this.value.getLong();
}

function QuotaNonPagedPoolUsage()
{
this.value.getPos = 28;
return this.value.getLong();
}

function PagefileUsage()
{
this.value.getPos = 32;
return this.value.getLong();
}

function PeakPagefileUsage()
{
this.value.getPos = 36;
return this.value.getLong();
}
}

function getMemInfo(memInfo)
{
if (getPMemInfo(getCurrentProcess(), memInfo, 40))
{
trace("Memory Usage: " + memInfo.WorkingSetSize());
}
}

if (success)
{
memInfo = new MemInfo();

Application.setInterval(getMemInfo, 1000, memInfo);
}
Reply With Quote
  #7 (permalink)  
Old 01-20-2005, 07:47 AM
Junior Member
 
Join Date: Jan 2005
Posts: 7
Default Re:memory use of my application

thank you very much for fast and good support. your users need more examples and help on this windows api programming. the ideas and possibilities are endless... thanks!
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:37 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.