huskar-t / opcda

An OPC DA client written purely in Go
MIT License
20 stars 3 forks source link

运行example/subscribe/main.go观察到内存快速增长现象 #10

Closed evelive3 closed 4 months ago

evelive3 commented 4 months ago

Golang

go1.22.4 windows/amd64

OS

Windows 11 X64 23H2 OS build 22631.3737

OPC DA Server

MatrikonOPCSimulation_v1.7.1.0

操作步骤

将example/subscribe/main.go下载后,执行go build --ldflags "-s -w" .编译为exe可执行程序文件并运行

现象

刚运行时,内存占用2M image 运行10分钟后,内存占用6M image

后续还修改了example/read/main.go使之持续运行,也观察到同样的内存使用增加情况,不知道是否与Item的Release方法为空有关? https://github.com/huskar-t/opcda/blob/3c352b9c72cfa1764184e0163f32443b3b484edf/opcitem.go#L228-L230

huskar-t commented 4 months ago

@evelive3 you need to run it for more than an hour to see if the memory is stable around a certain value.Due to Go's memory model, part of the memory on the heap will be reused

huskar-t commented 4 months ago

@evelive3 I ran it for two hours and the memory was stable at around 5 MB.