Saturday, March 18, 2023
HomeGolangBenefits of Go Struct Memory Design - Technical Conversation

Benefits of Go Struct Memory Design – Technical Conversation

What are the benefits of Golang’s struct memory format contrasted to JVM-like shows language? Golang’s struct is structured type of like C/C++/ Corrosion struct, their area are squash right into a solitary memory area. An embedded struct (A struct with various other struct as the area), will certainly be squash right into the exact same area. Whereas, configuring language like Java, whatever is tip, so if you have non-primitive information enter your struct (or course), they will immediately come to be tip and also the information will certainly lie elsewhere, not in the exact same memory area.

What are the benefits of doing this? I can consider a couple of factors such as:

  1. It’s simple to encode/decode binary information right into struct, simply unload the struct binaries.
  2. Cache area. Having closer memory area enhances cache hit price. This tbh I’m not so certain if it matters that a lot.
  3. Passing struct duplicates its inner memory by default. This can lowers insects triggered by unintended alteration to the struct.

Exist any type of various other factors? I seem like those 3 factors are not that large an offer.


Most Popular

Recent Comments