On Tue, Sep 12, 2017 at 9:52 AM, <wolfkdy1...@gmail.com> wrote: > > To be precise, I want to know if the garbage-collection thread still runs if > the program is started from C++ main-entry. > I think a pure golang program will start the gc-thread before the 'func > main(){}' but I don't know if it still holds true if the golang-part is > only a static-library.
It's not precisely accurate to see that there is a garbage-collection thread (there is a "system monitor" thread) but it is accurate to say that Go garbage collection works in parallel when linked into a C program just as it does in a normal Go program. The Go runtime will start threads as needed either way. Ian > 在 2017年9月13日星期三 UTC+8上午12:42:15,wolfk...@gmail.com写道: >> >> By using cgo, I wrappered some complex code written by golang into a >> static-lib and call into the lib >> from C++. >> My question is: the process will run from a c++ main-entry. Will golang's >> gc-background thread work in this way? I'm worried that the entry is from >> C++ code and golang's vm-environment may not be complete so that gc won't >> work and there will be memory-leaks. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.