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

2020-03-09 Thread Jake Montgomery
On Monday, March 9, 2020 at 1:37:00 PM UTC-4, Nitish Saboo wrote: > > Hi Jake, > > The memory usage remains constant when the rest of the service is > running.Only when LoadPatternDB() method is called within the service, > Memory Consumption increases which actually should not happen. > I am

[go-nuts] Re: I'm writing my website in golang but there is issue called 404 page not found

2020-03-09 Thread Amnon Baron Cohen
Also worth adding some unit tests, including one which reproduces your 404 error. See https://www.youtube.com/watch?v=hVFEV-ieeew for a great video about how to add these tests. On Monday, 9 March 2020 14:53:20 UTC, anderso...@blacklane.com wrote: > > please post the code as text. Either in a

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

2020-03-09 Thread Nitish Saboo
Hi Jake, The memory usage remains constant when the rest of the service is running.Only when LoadPatternDB() method is called within the service, Memory Consumption increases which actually should not happen. I am assuming if there is a memory leak while calling this method because the memory

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Marcin Romaszewicz
I'm using Uber's zap logger in production systems ( https://github.com/uber-go/zap). It is designed to emit structured JSON logs and do the minimal amount of allocations possible. It's a completely different interface from Go's log package, but that is where the efficiency comes from. I'd highly

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Vasiliy Tolstov
пн, 9 мар. 2020 г. в 19:36, Axel Wagner : > IMO, there really isn't a super good answer. The simple answer is: You > need to delay the actual `fmt.Sprintf` call as long as possible. Which > generally means, that the interface you consume (to allow the user to > direct and configure logging) will

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Vasiliy Tolstov
пн, 9 мар. 2020 г. в 19:41, andrey mirtchovski : > to avoid allocations you have to hint at the type of what you're going > to print. for example see/use zerolog: https://github.com/rs/zerolog Tanks, I saw it. But mostly i want to avoid typing hint -- Vasiliy Tolstov, e-mail:

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread andrey mirtchovski
to avoid allocations you have to hint at the type of what you're going to print. for example see/use zerolog: https://github.com/rs/zerolog On Mon, Mar 9, 2020 at 10:36 AM 'Axel Wagner' via golang-nuts wrote: > > IMO, there really isn't a super good answer. The simple answer is: You need > to

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread 'Axel Wagner' via golang-nuts
IMO, there really isn't a super good answer. The simple answer is: You need to delay the actual `fmt.Sprintf` call as long as possible. Which generally means, that the interface you consume (to allow the user to direct and configure logging) will need to reflect formatting and all kinds of things

Re: [go-nuts] append slice concurrently without lock,after that panic occurred when iterate the slice

2020-03-09 Thread Jan Mercl
On Mon, Mar 9, 2020 at 4:16 PM Yuu LongXue wrote: > > Hi all, > > Slice is not thread safe for write operation if without lock, this is true > and I know this feature. but recently, I got a panic which caused by writing > a slice concurrently with out lock occasionally and I can't figure out

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

2020-03-09 Thread Jake Montgomery
You may indeed have a leak. I did not check your code that carefully. But i do wonder about your statement: > > 1)As soon as I call LoadPatternDB() method in parser.go there is some > increase in memory consumption(some memory leak). Ideally that should not > have happened. > Go is a garbage

[go-nuts] Re: append slice concurrently without lock,after that panic occurred when iterate the slice

2020-03-09 Thread Jake Montgomery
It seems like you start your post by acknowledging that you have a race. But you are wondering why that race is causing a panic? Is that a correct assessment of you post? A race condition can cause all sorts of bad behavior. Some may behave "normally" 99.9% of the time, then cause an

Re: [go-nuts] append slice concurrently without lock,after that panic occurred when iterate the slice

2020-03-09 Thread burak serdar
On Mon, Mar 9, 2020 at 9:16 AM Yuu LongXue wrote: > > Hi all, > > Slice is not thread safe for write operation if without lock, this is true > and I know this feature. but recently, I got a panic which caused by writing > a slice concurrently with out lock occasionally and I can't figure out

[go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Vasiliy Tolstov
Hi! I have some logging package and after memory profiling saw that for disabled log levels i'm allocate memory for message. For example i'm send in logger only Info level. So i want to avoid Debug/Trace stuff. but memory profiling says that for call log.Tracef("my message %v", msg) i'm allocate

[go-nuts] append slice concurrently without lock,after that panic occurred when iterate the slice

2020-03-09 Thread Yuu LongXue
Hi all, Slice is not thread safe for write operation if without lock, this is true and I know this feature. but recently, I got a panic which caused by writing a slice concurrently with out lock occasionally and I can't figure out why. ### the process as below: 1. define a slice: var x

[go-nuts] Re: I'm writing my website in golang but there is issue called 404 page not found

2020-03-09 Thread anderson . queiroz
please post the code as text. Either in a github/whatever repo or here, but please, as text and a runnable code. I don't see you registering any handler for */register.html*, you have one for */register* only. Also if the method is not POST, you should return *405 Method Not Allowed *instead

[go-nuts] Mem-Leak in Go method

2020-03-09 Thread Nitish Saboo
Hi Following are my Go code and C header file and C wrapper code parser.go == var f *os.File func LoadPatternDB(patterndb string) { path := C.CString(patterndb) defer C.free(unsafe.Pointer(path)) C.load_pattern_db(path, (C.key_value_cb)(unsafe.Pointer(C.callOnMeGo_cgo))) } //export