簡體   English   中英

為給定程序使用/ usr / bin / time的內存使用情況

[英]Memory usage using /usr/bin/time for a giving program

我想知道如何使用time命令收集一個程序/命令(例如gcc ...)的內存使用情況。 “ time”命令的文檔中報告了許多屬性。 我不知道應該使用哪一個:

記憶

   %M     Maximum resident set size of the process during its lifetime,
          in Kbytes.

   %t     (Not in tcsh(1).)  Average resident set size of the process,
          in Kbytes.

   %K     Average total (data+stack+text) memory use of the process, in
          Kbytes.

   %D     Average size of the process's unshared data area, in Kbytes.

   %p     (Not in tcsh(1).)  Average size of the process's unshared
          stack space, in Kbytes.

   %X     Average size of the process's shared text space, in Kbytes.

   %Z     (Not in tcsh(1).)  System's page size, in bytes.  This is a
          per-system constant, but varies between systems.

   %F     Number of major page faults that occurred while the process
          was running.  These are faults where the page has to be read
          in from disk.

   %R     Number of minor, or recoverable, page faults.  These are
          faults for pages that are not valid but which have not yet
          been claimed by other virtual pages.  Thus the data in the
          page is still valid but the system tables must be updated.

   %W     Number of times the process was swapped out of main memory.

   %c     Number of times the process was context-switched involuntarily
          (because the time slice expired).

   %w     Number of waits: times that the program was context-switched
          voluntarily, for instance while waiting for an I/O operation
          to complete.

內存使用並不意味着太多(這是一個模糊的術語),因為進程可以在運行時使用mmap(2)請求更多的虛擬內存 (通常由malloc ....調用)並使用munmap釋放該內存(但free通常不調用munmap而只是將釋放的內存標記為可用於將來的malloc

因此內存使用是動態的 ; 您可以閱讀proc(5)並通過/proc/1234/maps/proc/1234/status/proc/1234/statm等查詢pid 1234進程的瞬時狀態...另請參見getrusage(2 )

您可能會通過不同的方法感興趣:平均或最大RSS ,地址空間的大小, 工作集等。 如果您在某處告訴(或記錄)某個度量,則可能應該解釋該度量的方式和方式(例如,說:“平均總內存1234KB,以time %K度量...”)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM