Code Monkey home page Code Monkey logo

Comments (6)

hiferoz avatar hiferoz commented on August 16, 2024

I tested each tag one by one using client.ReadItem("tag") and all tags with client.Read(). I am new to Go as well as OPC, so this flies over my head :) I hope you can point me in the right direction:

For below tags, the memory usage is around 7MB and does not keep on increasing:
[]string{ "Random.PsBool1", "Random.PsFloat1", "Random.PsInteger1", "Random.PsState1", "Random.PsBitSet1"],

For below tags, the memory keeps on increasing:
[]string{ "Random.PsString1", "Random.PsFloatArray1", "Random.PsByteArray1", "Random.PsVariant1", "Random.PsDateTime1"},

from opc.

konimarti avatar konimarti commented on August 16, 2024

@hiferoz thanks for your concern. Right off the bat, I don't think there's a memory leak issue. Go uses an internal garbage collector to deal with all memory related allocations (so, no malloc / freeing issues as in C). The memory growth you noticed might be related to how the garbage collector works but I'm not very familiar with the details there.

We have been running this code over weeks with thousands of tags and constantly monitor the app's memory requirements with Prometheus: the memory usage stays constant. For hundreds of tags per app, we noticed a memory usage between 10-15 MB which remains flat over time.

However, if you notice that it keeps growing and growing or crashes your app / computer, please let us know and provide some more details (i.e. what go version, etc.)

from opc.

hiferoz avatar hiferoz commented on August 16, 2024

@konimarti thanks for your reply. I am afraid, the issue persists and it is quite strange one as it is somehow related to Tag Type. As soon as I add Tag Type of String, the memory keeps on growing. I have tested it using GrayBox, Matrikon and Prosys Simulators, and on both 386 and amd64 environments. Currently, I am using below Go version:

`Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\feroz>go env
set GO111MODULE=
set GOARCH=386
set GOBIN=
set GOCACHE=C:\Users\feroz\AppData\Local\go-build
set GOENV=C:\Users\feroz\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=386
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\GoPrj
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\Go386
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Go386\pkg\tool\windows_386
set GCCGO=gccgo
set GO386=sse2
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m32 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\feroz\AppData\Local\T
emp\go-build074323446=/tmp/go-build -gno-record-gcc-switches

C:\Users\feroz>go version
go version go1.13.4 windows/386
`
I also directly build and tested your opciapi and called it using a simple httpclient. The opcapi kept on growing, as well as soon as I added a String Tag in opcapi.conf. Once I remove the String Tag, the memory stays at 7MB.

So, I am really stuck here and I was hoping you can spend sometime to help me out here. Let me know, I am willing to engage your paid professional services to work on this.

Regards,
Feroz

from opc.

konimarti avatar konimarti commented on August 16, 2024

@hiferoz try to add a time.Sleep(100*time.Millisecond) in your for-loop and please try again and check if your memory usage now remains flat after 2-3mins:

for {
	fmt.Println(client.Read()) 
        time.Sleep(100 * time.Millisecond)
}

from opc.

hiferoz avatar hiferoz commented on August 16, 2024

@konimarti thank you so much. It seems, it stabilized at around 11MB. I will continue to test and monitor with other Tag Types as well. However, could you please explain to me this behavior?

from opc.

konimarti avatar konimarti commented on August 16, 2024

@hiferoz I think the garbage collector didn't have enough time to collect the garbage? Anyway, a polling in intervals is a more realistic scenario. Glad it works for you now!

from opc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.