Re: [go-nuts] Mem-Leak in Go method

2020-03-16 Thread Robert Engels
Because the same Go routine doesn’t mean it will be called on the same thread. It is essentially a race condition. I could be wrong - I’m sure someone will correct me. :) > On Mar 16, 2020, at 9:32 AM, Nitish Saboo wrote: > >  > Hi Robert, > > Looks like pattern_db is a global. Are you sure

Re: [go-nuts] Mem-Leak in Go method

2020-03-16 Thread Nitish Saboo
Hi Robert, Looks like pattern_db is a global. Are you sure you don’t have multiple Go routines calling the load? The global changes may not be visible- so the free is doing nothing. patterndb is a global variable on C side.load method is getting called from a single go routine every 3 mins.I used

Re: [go-nuts] Mem-Leak in Go method

2020-03-16 Thread Robert Engels
I would also use pprof and ensure your Go code is not leaking memory. There are multiple tutorials on using memory profilers to detect memory leaks. > On Mar 16, 2020, at 9:12 AM, Robert Engels wrote: > >  > Looks like pattern_db is a global. Are you sure you don’t have multiple Go > routine

Re: [go-nuts] Mem-Leak in Go method

2020-03-16 Thread Robert Engels
Looks like pattern_db is a global. Are you sure you don’t have multiple Go routines calling the load? The global changes may not be visible- so the free is doing nothing. You probably need synchronization or pinning the access routine to a thread. > On Mar 16, 2020, at 9:03 AM, Nitish Saboo

Re: [go-nuts] Mem-Leak in Go method

2020-03-16 Thread Nitish Saboo
Hi, >From reading the code, I assume that the `pattern_db_new()` does some sort of allocation of a new pattern DB. I don't see any code releasing the pattern DB. Is that just missing from your post or something that some automatic mechanism does? >>Apologies, that part got missed in the code snip

Re: [go-nuts] Mem-Leak in Go method

2020-03-16 Thread Gregor Best
This might be a dumb question but... From reading the code, I assume that the `pattern_db_new()` does some sort of allocation of a new pattern DB. I don't see any code releasing the pattern DB. Is that just missing from your post or something that some automatic mechanism does? If not, that