Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
abf50e8c
Commit
abf50e8c
authored
13 years ago
by
Nat Goodspeed
Browse files
Options
Downloads
Patches
Plain Diff
CHOP-753: Fix compile errors in LLMemoryInfo Windows-specific code.
parent
01607fe4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/llcommon/llsys.cpp
+45
-27
45 additions, 27 deletions
indra/llcommon/llsys.cpp
indra/llcommon/llsys.h
+4
-0
4 additions, 0 deletions
indra/llcommon/llsys.h
with
49 additions
and
27 deletions
indra/llcommon/llsys.cpp
+
45
−
27
View file @
abf50e8c
...
@@ -665,7 +665,7 @@ static U32 LLMemoryAdjustKBResult(U32 inKB)
...
@@ -665,7 +665,7 @@ static U32 LLMemoryAdjustKBResult(U32 inKB)
U32
LLMemoryInfo
::
getPhysicalMemoryKB
()
const
U32
LLMemoryInfo
::
getPhysicalMemoryKB
()
const
{
{
#if LL_WINDOWS
#if LL_WINDOWS
return
LLMemoryAdjustKBResult
(
mStatsMap
[
"Total Physical KB"
]);
return
LLMemoryAdjustKBResult
(
mStatsMap
[
"Total Physical KB"
]
.
asInteger
()
);
#elif LL_DARWIN
#elif LL_DARWIN
// This might work on Linux as well. Someone check...
// This might work on Linux as well. Someone check...
...
@@ -712,9 +712,13 @@ U32 LLMemoryInfo::getPhysicalMemoryClamped() const
...
@@ -712,9 +712,13 @@ U32 LLMemoryInfo::getPhysicalMemoryClamped() const
//static
//static
void
LLMemoryInfo
::
getAvailableMemoryKB
(
U32
&
avail_physical_mem_kb
,
U32
&
avail_virtual_mem_kb
)
void
LLMemoryInfo
::
getAvailableMemoryKB
(
U32
&
avail_physical_mem_kb
,
U32
&
avail_virtual_mem_kb
)
{
{
// Sigh, this shouldn't be a static method, then we wouldn't have to
// reload this data separately from refresh()
LLSD
statsMap
(
loadStatsMap
(
loadStatsArray
()));
#if LL_WINDOWS
#if LL_WINDOWS
avail_physical_mem_kb
=
mS
tatsMap
[
"Avail Physical KB"
];
avail_physical_mem_kb
=
s
tatsMap
[
"Avail Physical KB"
]
.
asInteger
()
;
avail_virtual_mem_kb
=
mS
tatsMap
[
"Avail Virtual KB"
];
avail_virtual_mem_kb
=
s
tatsMap
[
"Avail Virtual KB"
]
.
asInteger
()
;
#elif LL_DARWIN
#elif LL_DARWIN
// mStatsMap is derived from vm_stat, look for (e.g.) "kb free":
// mStatsMap is derived from vm_stat, look for (e.g.) "kb free":
...
@@ -839,22 +843,35 @@ LLSD LLMemoryInfo::getStatsArray() const
...
@@ -839,22 +843,35 @@ LLSD LLMemoryInfo::getStatsArray() const
}
}
LLMemoryInfo
&
LLMemoryInfo
::
refresh
()
LLMemoryInfo
&
LLMemoryInfo
::
refresh
()
{
mStatsArray
=
loadStatsArray
();
// Recast same data as mStatsMap for easy access
mStatsMap
=
loadStatsMap
(
mStatsArray
);
LL_DEBUGS
(
"LLMemoryInfo"
)
<<
"Populated mStatsMap:
\n
"
;
LLSDSerialize
::
toPrettyXML
(
mStatsMap
,
LL_CONT
);
LL_ENDL
;
return
*
this
;
}
LLSD
LLMemoryInfo
::
loadStatsArray
()
{
{
// This implementation is derived from stream() code (as of 2011-06-29).
// This implementation is derived from stream() code (as of 2011-06-29).
mS
tatsArray
=
LLSD
::
emptyArray
();
LLSD
s
tatsArray
(
LLSD
::
emptyArray
()
)
;
#if LL_WINDOWS
#if LL_WINDOWS
MEMORYSTATUSEX
state
;
MEMORYSTATUSEX
state
;
state
.
dwLength
=
sizeof
(
state
);
state
.
dwLength
=
sizeof
(
state
);
GlobalMemoryStatusEx
(
&
state
);
GlobalMemoryStatusEx
(
&
state
);
mS
tatsArray
.
append
(
LLSDArray
(
"Percent Memory use"
)(
LLSD
::
Integer
(
state
.
dwMemoryLoad
)));
s
tatsArray
.
append
(
LLSDArray
(
"Percent Memory use"
)(
LLSD
::
Integer
(
state
.
dwMemoryLoad
)));
mS
tatsArray
.
append
(
LLSDArray
(
"Total Physical KB"
)
(
LLSD
::
Integer
(
state
.
ullTotalPhys
/
1024
)));
s
tatsArray
.
append
(
LLSDArray
(
"Total Physical KB"
)
(
LLSD
::
Integer
(
state
.
ullTotalPhys
/
1024
)));
mS
tatsArray
.
append
(
LLSDArray
(
"Avail Physical KB"
)
(
LLSD
::
Integer
(
state
.
ullAvailPhys
/
1024
)));
s
tatsArray
.
append
(
LLSDArray
(
"Avail Physical KB"
)
(
LLSD
::
Integer
(
state
.
ullAvailPhys
/
1024
)));
mS
tatsArray
.
append
(
LLSDArray
(
"Total page KB"
)
(
LLSD
::
Integer
(
state
.
ullTotalPageFile
/
1024
)));
s
tatsArray
.
append
(
LLSDArray
(
"Total page KB"
)
(
LLSD
::
Integer
(
state
.
ullTotalPageFile
/
1024
)));
mS
tatsArray
.
append
(
LLSDArray
(
"Avail page KB"
)
(
LLSD
::
Integer
(
state
.
ullAvailPageFile
/
1024
)));
s
tatsArray
.
append
(
LLSDArray
(
"Avail page KB"
)
(
LLSD
::
Integer
(
state
.
ullAvailPageFile
/
1024
)));
mS
tatsArray
.
append
(
LLSDArray
(
"Total Virtual KB"
)
(
LLSD
::
Integer
(
state
.
ullTotalVirtual
/
1024
)));
s
tatsArray
.
append
(
LLSDArray
(
"Total Virtual KB"
)
(
LLSD
::
Integer
(
state
.
ullTotalVirtual
/
1024
)));
mS
tatsArray
.
append
(
LLSDArray
(
"Avail Virtual KB"
)
(
LLSD
::
Integer
(
state
.
ullAvailVirtual
/
1024
)));
s
tatsArray
.
append
(
LLSDArray
(
"Avail Virtual KB"
)
(
LLSD
::
Integer
(
state
.
ullAvailVirtual
/
1024
)));
#elif LL_DARWIN
#elif LL_DARWIN
uint64_t
phys
=
0
;
uint64_t
phys
=
0
;
...
@@ -863,7 +880,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
...
@@ -863,7 +880,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
if
(
sysctlbyname
(
"hw.memsize"
,
&
phys
,
&
len
,
NULL
,
0
)
==
0
)
if
(
sysctlbyname
(
"hw.memsize"
,
&
phys
,
&
len
,
NULL
,
0
)
==
0
)
{
{
mS
tatsArray
.
append
(
LLSDArray
(
"Total Physical KB"
)(
LLSD
::
Integer
(
phys
/
1024
)));
s
tatsArray
.
append
(
LLSDArray
(
"Total Physical KB"
)(
LLSD
::
Integer
(
phys
/
1024
)));
}
}
else
else
{
{
...
@@ -925,7 +942,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
...
@@ -925,7 +942,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
<<
"' in vm_stat line: "
<<
line
<<
LL_ENDL
;
<<
"' in vm_stat line: "
<<
line
<<
LL_ENDL
;
continue
;
continue
;
}
}
mS
tatsArray
.
append
(
LLSDArray
(
"page size"
)(
pagesizekb
));
s
tatsArray
.
append
(
LLSDArray
(
"page size"
)(
pagesizekb
));
}
}
else
if
(
boost
::
regex_match
(
line
,
matched
,
stat_rx
))
else
if
(
boost
::
regex_match
(
line
,
matched
,
stat_rx
))
{
{
...
@@ -951,7 +968,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
...
@@ -951,7 +968,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
continue
;
continue
;
}
}
// Store this statistic.
// Store this statistic.
mS
tatsArray
.
append
(
LLSDArray
(
key
)(
value
));
s
tatsArray
.
append
(
LLSDArray
(
key
)(
value
));
// Is this in units of pages? If so, convert to Kb.
// Is this in units of pages? If so, convert to Kb.
static
const
LLSD
::
String
pages
(
"Pages "
);
static
const
LLSD
::
String
pages
(
"Pages "
);
if
(
key
.
substr
(
0
,
pages
.
length
())
==
pages
)
if
(
key
.
substr
(
0
,
pages
.
length
())
==
pages
)
...
@@ -959,7 +976,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
...
@@ -959,7 +976,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
// Synthesize a new key with kb in place of Pages
// Synthesize a new key with kb in place of Pages
LLSD
::
String
kbkey
(
"kb "
);
LLSD
::
String
kbkey
(
"kb "
);
kbkey
.
append
(
key
.
substr
(
pages
.
length
()));
kbkey
.
append
(
key
.
substr
(
pages
.
length
()));
mS
tatsArray
.
append
(
LLSDArray
(
kbkey
)(
value
*
pagesizekb
));
s
tatsArray
.
append
(
LLSDArray
(
kbkey
)(
value
*
pagesizekb
));
}
}
}
}
else
if
(
boost
::
regex_match
(
line
,
matched
,
cache_rx
))
else
if
(
boost
::
regex_match
(
line
,
matched
,
cache_rx
))
...
@@ -981,7 +998,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
...
@@ -981,7 +998,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
<<
"' in vm_stat line: "
<<
line
<<
LL_ENDL
;
<<
"' in vm_stat line: "
<<
line
<<
LL_ENDL
;
continue
;
continue
;
}
}
mS
tatsArray
.
append
(
LLSDArray
(
cache_keys
[
i
])(
value
));
s
tatsArray
.
append
(
LLSDArray
(
cache_keys
[
i
])(
value
));
}
}
}
}
else
else
...
@@ -997,7 +1014,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
...
@@ -997,7 +1014,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
phys
=
(
U64
)(
sysconf
(
_SC_PHYS_PAGES
))
*
(
U64
)(
sysconf
(
_SC_PAGESIZE
)
/
1024
);
phys
=
(
U64
)(
sysconf
(
_SC_PHYS_PAGES
))
*
(
U64
)(
sysconf
(
_SC_PAGESIZE
)
/
1024
);
mS
tatsArray
.
append
(
LLSDArray
(
"Total Physical KB"
)(
phys
));
s
tatsArray
.
append
(
LLSDArray
(
"Total Physical KB"
)(
phys
));
#elif LL_LINUX
#elif LL_LINUX
std
::
ifstream
meminfo
(
MEMINFO_FILE
);
std
::
ifstream
meminfo
(
MEMINFO_FILE
);
...
@@ -1048,7 +1065,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
...
@@ -1048,7 +1065,7 @@ LLMemoryInfo& LLMemoryInfo::refresh()
continue
;
continue
;
}
}
// Store this statistic.
// Store this statistic.
mS
tatsArray
.
append
(
LLSDArray
(
key
)(
value
));
s
tatsArray
.
append
(
LLSDArray
(
key
)(
value
));
}
}
else
else
{
{
...
@@ -1067,19 +1084,20 @@ LLMemoryInfo& LLMemoryInfo::refresh()
...
@@ -1067,19 +1084,20 @@ LLMemoryInfo& LLMemoryInfo::refresh()
#endif
#endif
// Recast same data as mStatsMap for easy access
return
statsArray
;
BOOST_FOREACH
(
LLSD
pair
,
inArray
(
mStatsArray
))
}
LLSD
LLMemoryInfo
::
loadStatsMap
(
const
LLSD
&
statsArray
)
{
LLSD
statsMap
;
BOOST_FOREACH
(
LLSD
pair
,
inArray
(
statsArray
))
{
{
// Specify asString() to disambiguate map indexing from array
// Specify asString() to disambiguate map indexing from array
// subscripting.
// subscripting.
mS
tatsMap
[
pair
[
0
].
asString
()]
=
pair
[
1
];
s
tatsMap
[
pair
[
0
].
asString
()]
=
pair
[
1
];
}
}
return
statsMap
;
LL_DEBUGS
(
"LLMemoryInfo"
)
<<
"Populated mStatsMap:
\n
"
;
LLSDSerialize
::
toPrettyXML
(
mStatsMap
,
LL_CONT
);
LL_ENDL
;
return
*
this
;
}
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
s
,
const
LLOSInfo
&
info
)
std
::
ostream
&
operator
<<
(
std
::
ostream
&
s
,
const
LLOSInfo
&
info
)
...
...
This diff is collapsed.
Click to expand it.
indra/llcommon/llsys.h
+
4
−
0
View file @
abf50e8c
...
@@ -141,6 +141,10 @@ class LL_COMMON_API LLMemoryInfo
...
@@ -141,6 +141,10 @@ class LL_COMMON_API LLMemoryInfo
LLMemoryInfo
&
refresh
();
LLMemoryInfo
&
refresh
();
private:
private:
// These methods are used to set mStatsArray and mStatsMap.
static
LLSD
loadStatsArray
();
static
LLSD
loadStatsMap
(
const
LLSD
&
);
// Memory stats for getStatsArray(). It's straightforward to convert that
// Memory stats for getStatsArray(). It's straightforward to convert that
// to getStatsMap() form, less so to reconstruct the original order when
// to getStatsMap() form, less so to reconstruct the original order when
// converting the other way.
// converting the other way.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment