由于最近我的 filebeat 频繁地 out of memory 。filebeat 只能限制 queue 条数,而不能限制 cache 内存大小,准备小小改造一下
type common.MapStr map[string]interface{}
type EventCache struct {
m common.MapStr
}
type EventFlags uint8
type beat.Event struct {
Timestamp time.Time
Meta common.MapStr
Fields common.MapStr
Private interface{} // for beats private use
TimeSeries bool // true if the event contains timeseries data
}
type Event struct {
Content beat.Event
Flags EventFlags
Cache EventCache
}
想请问下怎么在运行时优雅地计算 Event 这个结构所占用的内存大小,看到说 unsafe.sizeof 有很多问题,还说这个只是在编译时计算。 不优雅也行,野蛮点也可以。。。