ballast

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

package ballast 提供基于"压舱石"(ballast)的GC优化工具 通过预分配长期持有的大块内存,调整Go垃圾回收的触发阈值,减少GC频率 适用于内存使用频繁波动的服务,需根据实际内存需求合理配置

Index

Constants

View Source
const (
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

This section is empty.

Functions

func GC

func GC(limit int, percent int)

GC 初始化GC压舱石并配置GC百分比参数

参数说明:

limit: 压舱石内存大小(字节)
       - 若<=0,使用默认值128MB
       - 若>4GB,限制为4GB
percent: GC百分比(0-1000)
       - 若<=0,使用Go默认值(通常为100)
       - 若>1000,限制为1000

注意:函数仅执行一次,重复调用无效

func SetVerbose added in v1.1.0

func SetVerbose(v bool)

SetVerbose 设置是否输出初始化信息(线程安全)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL