修改golang最大内存限制
来源:互联网 发布:mysql replace into 编辑:程序博客网 时间:2024/05/21 06:56
摘自golang nut
You can tune the MHeapMap_Bits in malloc.h and arena_size in malloc.goc to reduce
memory usage, as long as they statisfy this:
(1UL << (12 + MHeapMap_Bits)) >= arena_size
(for example, I changed MHeapMap_Bits to 20, and arena_size to ”4LL<<30“, all tests
passed, and the size of bss sections is dropped to about 10MB for bin/go:
linux-amd64 go $ size bin/go # before
text data bss dec hex filename
4491897 9755233672424 38261873 247d471 bin/go
linux-amd64 go $ size bin/go # after
text data bss dec hex filename
4491924 97552 8506600 13096076 c7d48c bin/go
)
And for the record, this problem is not caused by the reserved VM space (which is 16GB
on 64-bit hosts, as they are mapped with PROT_NONE, i.e., they won't map to any physical
memory). Its real cause is the big runtime.mheap.
$ vi malloc.h
MHeapMap_Bits=16
$ vi malloc.goc
arena_size=1LL<<28
$ go install -a -v std
Then rebuilt my app which reduce its VPS footprint from 60MB to 20MB!!!
Previously:
MHeapMap_Bits=19
arena_size=1LL<<28
reduced the footprint to 24MB, so I imagine going lower has diminishing returns.
I can't help but wonder, if the memory usage is a bug, or whether these memory settings should be made available as flags in go build, or sometime in the future, the runtime will probably be improved to make good choices automatically. Is it worth putting in a feature request/bug report?
Given that the apps RSS is 2.5MB, I'm thinking the total footprint should be around 5-10MB? If so, there's probably more work to do and I would be happy to test.
However, knocking off ~70% of the ram requirements is absolutely fantastic, so thanks everyone for your time and helpful suggestions.
Cheers.
0 0
- 修改golang最大内存限制
- 修改hive内存限制
- gitlab修改最大项目限制
- 如何修改php内存限制
- mysql导入数据库文件最大限制的修改
- 修改ESX 最大2TB限制
- 修改linux最大进程数限制
- 修改centos打开文件最大限制
- Windows 2003 远程桌面最大用户数限制修改
- 修改cocosbuilder源码中的最大子目录限制
- 修改phpmyadmin的最大上传限制
- Linux系统修改最大文件限制
- Mac打开文件最大数限制修改
- phpmyadmin文件最大上传限制修改
- 解决WordPress最大上传文件大小限制修改
- Java虚拟机支持的最大内存限制
- Java虚拟机支持的最大内存限制
- Windows Server 2008最大内存限制
- easyui使用layou时自适应窗口
- GreenDAO(一)
- jboss7数据库连接池配置
- iOS框架整理
- Android Studio NDK开发 正确调用jni 及加入第三方so库需要注意的问题
- 修改golang最大内存限制
- Xcode7插件开发:从开发到拉到恶魔岛
- 堆排序
- Kotlin学习之枚举类
- VB 动态数组,文件读写
- 隐式转换
- 树莓派学习心得
- getRequestDispatcher 与 sendRedirect 的区别
- android实现水波纹效果