mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0031467: Foundation Classes, OSD_MemInfo - disable reading /proc/%d/status with Emscripten
OSD_MemInfo::Update() no more uses procfs with Emscripten. OSD_MemInfo::MemVirtual counter is now set to WebAssembly module heap length.
This commit is contained in:
parent
85b147584e
commit
420f5c8682
@ -37,6 +37,15 @@
|
|||||||
|
|
||||||
#include <OSD_MemInfo.hxx>
|
#include <OSD_MemInfo.hxx>
|
||||||
|
|
||||||
|
#if defined(__EMSCRIPTEN__)
|
||||||
|
#include <emscripten.h>
|
||||||
|
|
||||||
|
//! Return WebAssembly heap size in bytes.
|
||||||
|
EM_JS(size_t, OSD_MemInfo_getModuleHeapLength, (), {
|
||||||
|
return Module.HEAP8.length;
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : OSD_MemInfo
|
// function : OSD_MemInfo
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -146,23 +155,44 @@ void OSD_MemInfo::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__))
|
#elif defined(__EMSCRIPTEN__)
|
||||||
const struct mallinfo aMI = mallinfo();
|
if (IsActive (MemHeapUsage)
|
||||||
|
|| IsActive (MemWorkingSet)
|
||||||
|
|| IsActive (MemWorkingSetPeak))
|
||||||
|
{
|
||||||
|
// /proc/%d/status is not emulated - get more info from mallinfo()
|
||||||
|
const struct mallinfo aMI = mallinfo();
|
||||||
|
if (IsActive (MemHeapUsage))
|
||||||
|
{
|
||||||
|
myCounters[MemHeapUsage] = aMI.uordblks;
|
||||||
|
}
|
||||||
|
if (IsActive (MemWorkingSet))
|
||||||
|
{
|
||||||
|
myCounters[MemWorkingSet] = aMI.uordblks;
|
||||||
|
}
|
||||||
|
if (IsActive (MemWorkingSetPeak))
|
||||||
|
{
|
||||||
|
myCounters[MemWorkingSetPeak] = aMI.usmblks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (IsActive (MemVirtual))
|
||||||
|
{
|
||||||
|
myCounters[MemVirtual] = OSD_MemInfo_getModuleHeapLength();
|
||||||
|
}
|
||||||
|
#elif (defined(__linux__) || defined(__linux))
|
||||||
if (IsActive (MemHeapUsage))
|
if (IsActive (MemHeapUsage))
|
||||||
{
|
{
|
||||||
|
const struct mallinfo aMI = mallinfo();
|
||||||
myCounters[MemHeapUsage] = aMI.uordblks;
|
myCounters[MemHeapUsage] = aMI.uordblks;
|
||||||
}
|
}
|
||||||
#if defined(__EMSCRIPTEN__)
|
|
||||||
// /proc/%d/status is not emulated - get more info from mallinfo()
|
if (!IsActive (MemVirtual)
|
||||||
if (IsActive (MemWorkingSet))
|
&& !IsActive (MemWorkingSet)
|
||||||
|
&& !IsActive (MemWorkingSetPeak)
|
||||||
|
&& !IsActive (MemPrivate))
|
||||||
{
|
{
|
||||||
myCounters[MemWorkingSet] = aMI.uordblks;
|
return;
|
||||||
}
|
}
|
||||||
if (IsActive (MemWorkingSetPeak))
|
|
||||||
{
|
|
||||||
myCounters[MemWorkingSetPeak] = aMI.usmblks;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// use procfs on Linux
|
// use procfs on Linux
|
||||||
char aBuff[4096];
|
char aBuff[4096];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user