Find the memory usage, footprint, leak

本文介绍了Windows下使用UMDH工具和Linux下通过/proc/pid/smaps文件来查看进程的堆内存使用情况的方法,并提供了内存分配大小及调用堆栈等详细信息。此外,还提到了用于检测内存泄漏的工具Purify和valgrind。

Heap memory usage footprint:

Windows: Microsoft has UMDH tool to dump memory usage in heap. It contains the memory allocation, size and where(call statck to alloc this memory)

For example:

490 bytes + 30 at 1433D0 by BackTrace16
 78EDD036
 78D58EE6
 78D57BAC
 78D58E9E
 78D57AC0
 78EDEF73
 78ED7946
 78ED62D8
 78ED6416
 78EF3925
 78D59630


628 bytes + 38 at 143890 by BackTrace17
 78EDD036
 78D58F18
 78D57BAC
 78D58E9E
 78D57AC0
 78EDEF73
 78ED7946
 78ED62D8
 78ED6416
 78EF3925
 78D59630

 

Linux: /proc/pid/smaps or /proc/pid/maps has memory allocation and size information, but no call stack. smaps had more detail information than maps.

For example:

00110000-0012c000 r-xp 00000000 08:01 469893     /opt/CloudDesktopHost/lib/libcrutil.so
Size:                112 kB
Rss:                 112 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:        24 kB
Private_Dirty:        88 kB
Referenced:          112 kB
0012c000-0012d000 rw-p 0001c000 08:01 469893     /opt/CloudDesktopHost/lib/libcrutil.so
Size:                  4 kB
Rss:                   4 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         4 kB
Referenced:            4 kB

 

Memory leak check:

Purify, valgrind(Linux)

### 寻找具备更大内存容量的主机 当考虑寻找具有更高内存容量的不同主机时,可以利用CXL(Compute Express Link)技术来扩展系统的内存能力[^1]。通过采用支持CXL标准的新一代服务器平台,能够连接多种类型的存储器设备到单一系统上,并依据需求分配这些资源。 对于具体操作而言,在Linux环境中可以通过`atop`工具监控并分析现有硬件性能指标以及资源利用率情况[^2]。这有助于评估当前环境是否满足业务需求或是确实需要迁移至配备更多RAM的工作站或服务器节点。 为了实现这一目标,建议采取如下Python脚本作为示例框架来进行自动化检测与报告: ```python import os from subprocess import check_output def get_memory_info(): meminfo = {} with open("/proc/meminfo") as f: for line in f: key, value, unit = line.strip().split() meminfo[key[:-1]] = int(value) total_memory_gb = round(meminfo['MemTotal'] / 1024**2, 2) return total_memory_gb current_host_memory = get_memory_info() if current_host_memory < desired_minimum_memory_in_gb: # 假设desired_minimum_memory_in_gb是你期望达到的最小内存量 print(f"Current host does not meet the requirement. Memory size is {current_host_memory} GB.") else: print(f"The current host meets requirements with {current_host_memory} GB of RAM.") # 这里可以根据实际情况编写逻辑去查找其他符合条件的主机... ``` 此代码片段展示了如何读取 `/proc/meminfo` 文件中的数据以获取总物理内存大小,并将其转换为GB单位以便于比较。如果发现现有的机器不符合所需的最低阈值,则提示用户该主机不达标;反之则说明其符合预期条件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值