I use [HPZ800](https://helloacm.com/review-hpz800-server-workstation-hp-z800-workstation-desktop-pc-tower-computer-powerhouse-2x-intel-xeon-x5650-48gb-ddr3-memory-2tb-hdd-1gb-nvidia-quadro/) server at home, which is almost never turned off or restarted. And I see this today: > 我家里用的是[HPZ800](https://justyy.com/archives/2380)的服务器,所以长年不关机不重启,今天我看了CHROME好吃内存: ![image.png](https://ipfs.busy.org/ipfs/QmeFoAm3h6p4h6byNFC2DX9Qf3QDRzHPS1QnvGZx9rE3jn) And the Proceses Tab gives you rough idea how big memory is consumed by [Chrome.exe](https://helloacm.com/the-chromebookmark-cryptocurrency-lookup-tool-in-javascript/) > 在 Processes 页,操作系统列出了每个程序的吃内存情况,我们可以看到[CHROME](https://justyy.com/archives/5876)很吃内存。 ![image.png](https://ipfs.busy.org/ipfs/QmfKNusCNaDzg8jEtac9QNrh4U14LkbNJxU4s8n5NcQ9kW) However, I'd like to have a command line/tool that prints the memory usage for a given application. > 然而,我想着写一个小命令行工具,练练手。 [Github](https://github.com/DoctorLai/BatchUtils/blob/master/mem.cmd): ``` @echo off REM Calculate Total Memory Consumption for a Process setlocal enabledelayedexpansion set prog=%1 if [%1]==[] ( echo Usage: %0 Process goto end ) set sum=0 @for /F "tokens=5" %%i in ('tasklist ^| grep !prog!') do ( set mem=%%i set mem=!mem:,=! set /a sum=sum+!mem! ) echo Total Memory for !prog! is !sum! K set /a sum=sum/1024 echo Total Memory for !prog! is !sum! MB set /a sum=sum/1024 echo Total Memory for !prog! is !sum! GB :end ``` The idea is to use `for /f` in windows command line shell that will split the lines by default delimiter space and with `tokens=5` that will extract the memory usage for that process. > 原理就是用 `for /f` 来对每一行的输出进行字符串分割,`tokens=5` 会只选择第五列,也就是内存用量。 And we can use `!variable:,=!` to remove the `,` from the numbers and use `set /a` do sum up the number strings. However, you need to `setlocal enabledelayedexpansion` to allow variables updated at runtime (instead of pre-interpreted) > 我们需要用 `!variable:,=!` 来把数字中的逗号去掉,然后用 `set /a` 来进行数字叠加,最后面我们需要启用 `setlocal enabledelayedexpansion` 在WINDOWS[批处理](https://justyy.com/archives/2492)中开启变量支持 - 否则变量只会在批处理启动的时候替换一次。 However, at Linux, you wouldn't need this at all, because you can use `wc`, [awk](https://helloacm.com/awk-tutorial-when-are-you-expected-to-produce-your-next-witness-block-steemit/), `cut` etc existing tools to achieve the same task by piping these commands one by one i.e. Where there is a shell, there is a way! > 在LINUX下我们就不需要这么麻烦了,因为已经有很多现成好用的工具,比如 `wc`, [awk](https://justyy.com/archives/6111), `cut` 这些命令可以通过管道来完成同样的任务。 ![image.png](https://ipfs.busy.org/ipfs/QmTduNvYfPSY8dEuFmZ2KucayFMCW4qETxRkdcFu73zcRX) ## Support me and my work as a witness - [witness thread](https://steemit.com/witness-category/@justyy/justyy-just-another-witness) by 1. voting me [here](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=justyy), or 2. voting me as [a proxy](https://v2.steemconnect.com/sign/account-witness-proxy?proxy=justyy&approve=1). Thank you! **Some of My Contributions: [SteemIt Tutorials, Robots, Tools and APIs](https://helloacm.com/tools/steemit/)** Reposted to: https://helloacm.com/introducing-the-batch-utility-for-windows-mem-cmd/ > ## 支持我的工作 支持我成为 [见证人](https://steemit.com/cn/@justyy/5h6gyv-cn) > 1. [请在 这里 投我一票](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=justyy), 或者 > 2. 设置我 [为代理](https://v2.steemconnect.com/sign/account-witness-proxy?proxy=justyy&approve=1). > 谢谢您! 我的贡献:[SteemIt 工具、API接口、机器人和教程](https://helloacm.com/tools/steemit-tools/) > ## 股东工具 > 1. 成为股东:[代理5 SP 即可 (退出股东 输入 0即可)](https://helloacm.com/tools/steemit/delegate-form/?delegatee=justyy) > 2. [查询当前股东](https://helloacm.com/tools/steemit/list-of-delegators/?id=justyy) > 请注意:每次代理都是以最后一次输入的SP数量为标准,比如已经代理10 SP,想多代理5 SP则需要输入 最后的数字 15 SP(而不是 5!) 博文刚刚同步到了:https://justyy.com/archives/6413
post_id | 56,650,453 |
---|---|
author | justyy |
permlink | introducing-the-batch-utility-for-windows-mem-cmd-chrome |
category | programming |
json_metadata | {"links":["https:\/\/helloacm.com\/review-hpz800-server-workstation-hp-z800-workstation-desktop-pc-tower-computer-powerhouse-2x-intel-xeon-x5650-48gb-ddr3-memory-2tb-hdd-1gb-nvidia-quadro\/","https:\/\/justyy.com\/archives\/2380","https:\/\/helloacm.com\/the-chromebookmark-cryptocurrency-lookup-tool-in-javascript\/","https:\/\/justyy.com\/archives\/5876","https:\/\/github.com\/DoctorLai\/BatchUtils\/blob\/master\/mem.cmd","https:\/\/justyy.com\/archives\/2492","https:\/\/helloacm.com\/awk-tutorial-when-are-you-expected-to-produce-your-next-witness-block-steemit\/","https:\/\/justyy.com\/archives\/6111","https:\/\/steemit.com\/witness-category\/@justyy\/justyy-just-another-witness","https:\/\/steemconnect.com\/sign\/account_witness_vote?approve=1&witness=justyy","https:\/\/v2.steemconnect.com\/sign\/account-witness-proxy?proxy=justyy&approve=1","https:\/\/helloacm.com\/tools\/steemit\/","https:\/\/helloacm.com\/introducing-the-batch-utility-for-windows-mem-cmd\/","https:\/\/steemit.com\/cn\/@justyy\/5h6gyv-cn","https:\/\/helloacm.com\/tools\/steemit-tools\/","https:\/\/helloacm.com\/tools\/steemit\/delegate-form\/?delegatee=justyy","https:\/\/helloacm.com\/tools\/steemit\/list-of-delegators\/?id=justyy","https:\/\/justyy.com\/archives\/6413"],"tags":["programming","cn-programming","steemstem","busy","witness-category"],"image":["https:\/\/ipfs.busy.org\/ipfs\/QmeFoAm3h6p4h6byNFC2DX9Qf3QDRzHPS1QnvGZx9rE3jn"],"format":"markdown","app":"steemit\/0.1","community":"busy"} |
created | 2018-07-15 20:16:51 |
last_update | 2018-07-15 22:57:30 |
depth | 0 |
children | 1 |
net_rshares | 3,328,287,223,159 |
last_payout | 2018-07-22 20:16:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 6.127 SBD |
curator_payout_value | 0.996 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 3,840 |
author_reputation | 2,057,469,156,047,835 |
root_title | "Introducing the Batch Utility for Windows - mem.cmd 想知道CHROME到底有多占内存么?" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ace108 | 0 | 179,593,340,879 | 16% | ||
magicmonk | 0 | 112,102,490,379 | 50% | ||
warofcraft | 0 | 29,507,859,369 | 20% | ||
oldtimer | 0 | 85,407,420,280 | 3% | ||
justyy | 0 | 1,290,467,080,842 | 85% | ||
luneknight | 0 | 375,604,831 | 100% | ||
busy.pay | 0 | 627,023,058,957 | 5.59% | ||
happyukgo | 0 | 1,737,613,723 | 85% | ||
nokeh | 0 | 254,602,347 | 99% | ||
elizacheng | 0 | 4,760,683,916 | 21% | ||
steemitboard | 0 | 427,981,048 | 1% | ||
battleaxe | 0 | 4,476,669,691 | 5% | ||
frankintaiwan | 0 | 80,143,710 | 20% | ||
helo | 0 | 1,284,768,817 | 10% | ||
shenchensucc | 0 | 815,795,322 | 20% | ||
czechglobalhosts | 0 | 287,830,527,111 | 3% | ||
victorialuxx | 0 | 273,373,691 | 100% | ||
susanli3769 | 0 | 129,140,345,136 | 100% | ||
robinlee | 0 | 368,371,945 | 84.78% | ||
rainyapril | 0 | 593,200,441 | 99% | ||
al2ping | 0 | 105,081,237 | 99% | ||
liangfengyouren | 0 | 1,323,634,881 | 50% | ||
yasu24 | 0 | 5,846,364,377 | 20% | ||
jiangchen | 0 | 121,947,657 | 1% | ||
mangoanddaddy | 0 | 1,764,506,145 | 80% | ||
kangnajiang | 0 | 243,015,296 | 99% | ||
kikima | 0 | 431,246,098 | 99% | ||
fr3eze | 0 | 13,681,503,673 | 10% | ||
geass | 0 | 687,378,224 | 99% | ||
moonvoid | 0 | 610,390,398 | 100% | ||
skenan | 0 | 198,659,860,729 | 100% | ||
boontjie | 0 | 138,820,132 | 10% | ||
irenett | 0 | 995,964,352 | 100% | ||
rosatravels | 0 | 108,826,464,364 | 50% | ||
xuran | 0 | 5,075,463,584 | 100% | ||
awiwea1974 | 0 | 287,313,634 | 100% | ||
superbing | 0 | 12,183,209,448 | 85% | ||
dailyfortune | 0 | 311,046,819 | 95% | ||
xiaoshancun | 0 | 226,382,816 | 100% | ||
dailystats | 0 | 22,417,416,369 | 85% | ||
ayman101 | 0 | 335,350,271 | 100% | ||
vandadream | 0 | 23,209,236,583 | 100% | ||
steemline | 0 | 225,632,902 | 100% | ||
winniex | 0 | 5,039,190,227 | 10% | ||
jianan | 0 | 871,152,256 | 88.1% | ||
nada101 | 0 | 375,790,123 | 100% | ||
windowglass | 0 | 17,078,814,835 | 50% | ||
halleyleow | 0 | 2,841,862,833 | 100% | ||
cnbuddy | 0 | 4,417,892,011 | 0.1% | ||
nileelily | 0 | 4,083,739,530 | 100% | ||
chann | 0 | 5,502,830,475 | 20% | ||
daxiang | 0 | 265,562,826 | 99% | ||
jrvacation | 0 | 3,952,130,904 | 3% | ||
anxin | 0 | 2,167,588,089 | 88.25% | ||
coindzs | 0 | 186,874,104 | 100% | ||
cryptonewsly | 0 | 251,240,266 | 100% | ||
moobear | 0 | 243,904,160 | 99% | ||
maiyude | 0 | 1,865,001,947 | 5% | ||
madokami | 0 | 106,509,103 | 99% | ||
bhargavivkothari | 0 | 381,340,709 | 100% | ||
thetroublenotes | 0 | 254,945,476 | 2% | ||
nean | 0 | 592,303,351 | 99% | ||
foodielifestyle | 0 | 891,513,867 | 88.37% | ||
woolfe19861008 | 0 | 1,839,314,996 | 88.27% | ||
jerrywjl | 0 | 94,414,242 | 21% | ||
comingback | 0 | 255,918,638 | 12% | ||
dailychina | 0 | 15,228,845,200 | 85% | ||
vincenthan | 0 | 590,538,819 | 99% | ||
yjcps | 0 | 1,559,352,583 | 95% | ||
yuxuan | 0 | 284,503,092 | 99% | ||
dongfengman | 0 | 8,734,230,155 | 87.6% | ||
historylover | 0 | 723,335,854 | 100% | ||
serenazz | 0 | 926,702,854 | 87.96% | ||
yedda | 0 | 590,474,153 | 99% | ||
shentrading | 0 | 396,248,875 | 75.38% | ||
zasilla | 0 | 593,387,082 | 99% | ||
aaronstar | 0 | 58,816,718 | 99% | ||
ayanamoon | 0 | 52,576,283 | 99% | ||
ethanlee | 0 | 7,998,545,295 | 67.13% | ||
twinsnicole | 0 | 591,705,007 | 99% | ||
deepthinking | 0 | 593,523,481 | 99% | ||
asrizal | 0 | 138,955,027 | 100% | ||
wilfredn | 0 | 15,141,441,840 | 100% | ||
fanso | 0 | 980,718,242 | 78.94% | ||
asrizalmustafa | 0 | 150,262,226 | 100% | ||
abss | 0 | 90,029,266 | 11% | ||
ryenneleow | 0 | 1,018,154,303 | 100% | ||
casperleow | 0 | 816,831,428 | 80% | ||
lilypang22 | 0 | 3,896,451,912 | 74.18% | ||
fishdd | 0 | 75,941,013 | 2.5% | ||
vinnieleow | 0 | 1,167,685,783 | 100% | ||
zens | 0 | 590,287,453 | 99% | ||
steemitvip | 0 | 591,341,688 | 99% | ||
regals | 0 | 593,047,784 | 99% | ||
joelone | 0 | 591,871,046 | 99% | ||
ibrasteem | 0 | 164,173,976 | 100% | ||
sweet-jenny8 | 0 | 16,665,349,869 | 87.67% | ||
agoha | 0 | 216,527,822 | 50% | ||
laijihua | 0 | 608,608,559 | 100% | ||
rsmartt777 | 0 | 106,871,614 | 90% | ||
bambugrove | 0 | 149,720,021 | 30% | ||
astros | 0 | 2,695,125,333 | 100% | ||
laiyuehta | 0 | 466,491,497 | 87.2% | ||
turtlegraphics | 0 | 8,616,107,786 | 85% | ||
julian2013 | 0 | 8,505,829,112 | 100% | ||
witnesspage | 0 | 7,997,912,695 | 27% | ||
t1050108 | 0 | 517,255,641 | 100% | ||
jacekw.dev | 0 | 460,546,856 | 100% | ||
gameguide | 0 | 92,936,891 | 100% | ||
minminlou | 0 | 112,676,451 | 25% | ||
witnesstools | 0 | 8,242,241,706 | 85% | ||
humanheart | 0 | 115,045,476 | 100% |
Congratulations @justyy! You have completed the following achievement on Steemit and have been rewarded with new badge(s) : [![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/posts.png)](http://steemitboard.com/@justyy) Award for the number of posts published [![](https://steemitimages.com/70x70/http://steemitboard.com/notifications/postallweek.png)](http://steemitboard.com/@justyy) You published a post every day of the week <sub>_Click on the badge to view your Board of Honor._</sub> <sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub> To support your work, I also upvoted your post! **Do not miss the last post from @steemitboard:** [SteemitBoard World Cup Contest - Final results coming soon](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-final-contest-result-coming-soon) > You can upvote this notification to help all Steemit users. Learn why [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
post_id | 56,681,189 |
---|---|
author | steemitboard |
permlink | steemitboard-notify-justyy-20180716t051911000z |
category | programming |
json_metadata | {"image":["https:\/\/steemitboard.com\/img\/notify.png"]} |
created | 2018-07-16 05:19:09 |
last_update | 2018-07-16 05:19:09 |
depth | 1 |
children | 0 |
net_rshares | 0 |
last_payout | 2018-07-23 05:19:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 1,056 |
author_reputation | 38,705,954,145,809 |
root_title | "Introducing the Batch Utility for Windows - mem.cmd 想知道CHROME到底有多占内存么?" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |