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
f1ffcad0
Commit
f1ffcad0
authored
5 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Make memory stats more accurate to actual system state on win64 and darwin
parent
0698db56
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llcommon/llmemory.cpp
+51
-11
51 additions, 11 deletions
indra/llcommon/llmemory.cpp
with
51 additions
and
11 deletions
indra/llcommon/llmemory.cpp
+
51
−
11
View file @
f1ffcad0
...
@@ -85,12 +85,13 @@ void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_f
...
@@ -85,12 +85,13 @@ void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_f
void
LLMemory
::
updateMemoryInfo
()
void
LLMemory
::
updateMemoryInfo
()
{
{
#if LL_WINDOWS
#if LL_WINDOWS
PROCESS_MEMORY_COUNTERS
counters
;
PROCESS_MEMORY_COUNTERS_EX
counters
;
counters
.
cb
=
sizeof
(
counters
);
if
(
!
GetProcessMemoryInfo
(
GetCurrentProcess
(),
&
counters
,
sizeof
(
counters
)))
if
(
!
GetProcessMemoryInfo
(
GetCurrentProcess
(),
(
PROCESS_MEMORY_COUNTERS
*
)
&
counters
,
sizeof
(
counters
)))
{
{
LL_WARNS
()
<<
"GetProcessMemoryInfo failed"
<<
LL_ENDL
;
LL_WARNS
()
<<
"GetProcessMemoryInfo failed"
<<
LL_ENDL
;
return
;
return
;
}
}
sAllocatedMemInKB
=
U32Kilobytes
::
convert
(
U64Bytes
(
counters
.
WorkingSetSize
));
sAllocatedMemInKB
=
U32Kilobytes
::
convert
(
U64Bytes
(
counters
.
WorkingSetSize
));
...
@@ -98,26 +99,65 @@ void LLMemory::updateMemoryInfo()
...
@@ -98,26 +99,65 @@ void LLMemory::updateMemoryInfo()
sAllocatedPageSizeInKB
=
U32Kilobytes
::
convert
(
U64Bytes
(
counters
.
PagefileUsage
));
sAllocatedPageSizeInKB
=
U32Kilobytes
::
convert
(
U64Bytes
(
counters
.
PagefileUsage
));
sample
(
sVirtualMem
,
sAllocatedPageSizeInKB
);
sample
(
sVirtualMem
,
sAllocatedPageSizeInKB
);
U32Kilobytes
avail_phys
,
avail_virtual
;
MEMORYSTATUSEX
memorystat
;
LLMemoryInfo
::
getAvailableMemoryKB
(
avail_phys
,
avail_virtual
)
;
memorystat
.
dwLength
=
sizeof
(
memorystat
);
sMaxPhysicalMemInKB
=
llmin
(
avail_phys
+
sAllocatedMemInKB
,
sMaxHeapSizeInKB
);
if
(
!
GlobalMemoryStatusEx
(
&
memorystat
))
if
(
sMaxPhysicalMemInKB
>
sAllocatedMemInKB
)
{
{
sAvailPhysicalMemInKB
=
sMaxPhysicalMemInKB
-
sAllocatedMemInKB
;
LL_WARNS
()
<<
"GlobalMemoryStatusEx failed"
<<
LL_ENDL
;
return
;
}
#if (ADDRESS_SIZE==64)
sMaxPhysicalMemInKB
=
U32Kilobytes
::
convert
(
U64Bytes
(
memorystat
.
ullTotalPhys
));
sAvailPhysicalMemInKB
=
U32Kilobytes
::
convert
(
U64Bytes
(
memorystat
.
ullAvailPhys
));
#else
sMaxPhysicalMemInKB
=
llmin
(
U32Kilobytes
::
convert
(
U64Bytes
(
memorystat
.
ullTotalPhys
)),
sMaxHeapSizeInKB
);
if
(
sMaxPhysicalMemInKB
>
sAllocatedMemInKB
)
{
sAvailPhysicalMemInKB
=
U32Kilobytes
::
convert
(
U64Bytes
(
memorystat
.
ullAvailPhys
));
}
}
else
else
{
{
sAvailPhysicalMemInKB
=
U32Kilobytes
(
0
);
sAvailPhysicalMemInKB
=
U32Kilobytes
(
0
);
}
}
#endif
#elif LL_DARWIN
mach_task_basic_info_data_t
basicInfo
;
mach_msg_type_number_t
basicInfoCount
=
MACH_TASK_BASIC_INFO_COUNT
;
if
(
task_info
(
mach_task_self
(),
MACH_TASK_BASIC_INFO
,
(
task_info_t
)
&
basicInfo
,
&
basicInfoCount
)
==
KERN_SUCCESS
)
{
sAllocatedMemInKB
=
U64Bytes
(
basicInfo
.
resident_size
);
sample
(
sAllocatedMem
,
sAllocatedMemInKB
);
sAllocatedPageSizeInKB
=
U64Bytes
(
basicInfo
.
virtual_size
);
sample
(
sVirtualMem
,
sAllocatedPageSizeInKB
);
}
vm_size_t
page_size
;
vm_statistics64_data_t
vm_stats
;
mach_port_t
mach_port
=
mach_host_self
();
mach_msg_type_number_t
count
=
HOST_VM_INFO64_COUNT
;
if
(
KERN_SUCCESS
==
host_page_size
(
mach_port
,
&
page_size
)
&&
KERN_SUCCESS
==
host_statistics64
(
mach_port
,
HOST_VM_INFO64
,
(
host_info64_t
)
&
vm_stats
,
&
count
))
{
U64
total_memory
=
(
vm_stats
.
free_count
+
vm_stats
.
active_count
+
vm_stats
.
inactive_count
+
vm_stats
.
wire_count
+
vm_stats
.
compressor_page_count
)
*
page_size
;
sMaxPhysicalMemInKB
=
U64Bytes
(
total_memory
);
sAvailPhysicalMemInKB
=
U64Bytes
((
vm_stats
.
free_count
+
vm_stats
.
inactive_count
)
*
page_size
);
}
else
{
sMaxPhysicalMemInKB
=
U64Bytes
(
U32_MAX
);
sAvailPhysicalMemInKB
=
U64Bytes
(
U32_MAX
);
}
#else
#else
//not valid for other systems for now.
//not valid for other systems for now.
sAllocatedMemInKB
=
U64Bytes
(
LLMemory
::
getCurrentRSS
());
sAllocatedMemInKB
=
U64Bytes
(
LLMemory
::
getCurrentRSS
());
sMaxPhysicalMemInKB
=
U64Bytes
(
U32_MAX
);
sMaxPhysicalMemInKB
=
U64Bytes
(
U32_MAX
);
sAvailPhysicalMemInKB
=
U64Bytes
(
U32_MAX
);
sAvailPhysicalMemInKB
=
U64Bytes
(
U32_MAX
);
#endif
#endif
return
;
}
}
//
//
...
...
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