Paul Krill
Editor at Large

Go language revises memory model

news
Jul 15, 20222 mins

Go 1.19, due in August, aligns the Go memory model with the memory model used by C, C++, Java, JavaScript, Rust, and Swift.

a digital brain
Credit: Thinkstock

Go 1.19, an update of the Google-developed programming language due in August, introduces a revised memory model and new types that make it easier to use atomic values.

Now in a preview stage, Go 1.19 can be downloaded from go.dev. The release is still considered unstable at this point.

With Go 1.19, the language’s memory model has been revised to align Go with the memory model used by C, C++, Java, JavaScript, and Swift, according to release notes. Go 1.19 also features new types in the sync/atomic package that make it easier to use atomic values such as atomic.int64 and atomic.Pointer(T).

The Go memory model specifies conditions under which reads of a variable in one goroutine can be guaranteed to observe values produced by writes to the same variable in a different goroutine. Go only provides sequentially consistent atomics, not any of more relaxed forms offered in other languages.

Go 1.19 also introduces a “small” change to the language, consisting of a correction to the scope of type parameters in method declarations. Existing programs are unaffected. Go 1.19 follows the momentous release in March of Go 1.18, which featured long-sought generics capabilities. 

Other new features and improvements in Go 1.19:

  • The runtime now includes support for a soft memory limit. The limit includes the Go heap and other memory managed by the runtime and excludes external memory sources such as mappings of the binary, memory managed in other languages, and memory held by the OS on behalf of the Go program. Also, the runtime now schedules fewer GC worker routines on idle OS threads when the application is idle enough to force a periodic GC cycle.
  • The compiler now uses a jump table to implement large integer and string switch statements. Performance improvements for the switch statement vary but can be on the order of 20% faster.
  • The release supports links, lists, and clearer headings in doc comments.
  • The build constraint, unix, is now recognized in //go:build lines.
  • Support is added for the Loongson 64-bit architecture LoongArch on Linux.
Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author