Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit751db4e

Browse files
authored
gh-132917: Use /proc/self/status for mem usage info. (#133544)
On Linux, use /proc/self/status for mem usage info. Using smaps_rollup is quite a lot slower andwe can get the similar info from /proc/self/status.
1 parent0a3ccb8 commit751db4e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎Python/gc_free_threading.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,8 +1927,7 @@ get_process_mem_usage(void)
19271927
}
19281928

19291929
#elif__linux__
1930-
// Linux, use smaps_rollup (Kernel >= 4.4) for RSS + Swap
1931-
FILE*fp=fopen("/proc/self/smaps_rollup","r");
1930+
FILE*fp=fopen("/proc/self/status","r");
19321931
if (fp==NULL) {
19331932
return-1;
19341933
}
@@ -1938,11 +1937,11 @@ get_process_mem_usage(void)
19381937
long longswap_kb=-1;
19391938

19401939
while (fgets(line_buffer,sizeof(line_buffer),fp)!=NULL) {
1941-
if (rss_kb==-1&&strncmp(line_buffer,"Rss:",4)==0) {
1942-
sscanf(line_buffer+4,"%lld",&rss_kb);
1940+
if (rss_kb==-1&&strncmp(line_buffer,"VmRSS:",6)==0) {
1941+
sscanf(line_buffer+6,"%lld",&rss_kb);
19431942
}
1944-
elseif (swap_kb==-1&&strncmp(line_buffer,"Swap:",5)==0) {
1945-
sscanf(line_buffer+5,"%lld",&swap_kb);
1943+
elseif (swap_kb==-1&&strncmp(line_buffer,"VmSwap:",7)==0) {
1944+
sscanf(line_buffer+7,"%lld",&swap_kb);
19461945
}
19471946
if (rss_kb!=-1&&swap_kb!=-1) {
19481947
break;// Found both

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp