TGViewer
„Chillin‘“ at Amazon „Chillin‘“ at Amazon @webapparch · 591 subscribers
Post #176 349
#go #goroutines

Go uses goroutines while a language like Java uses threads.

The creation of a goroutine does not require much memory - only 2kB of stack space. They grow by allocating and freeing heap storage as required. Threads on the other hand start out at 1Mb (500 times more), along with a region of memory called a guard page that acts as a guard between one thread’s memory and another.

A server handling incoming requests can therefore create one goroutine per request without a problem, but one thread per request will eventually lead to the dreaded OutOfMemoryError. This isn’t limited to Java - any language that uses OS threads as the primary means of concurrency will face this issue.

Threads have significant setup and teardown costs because it has to request resources from the OS and return it once its done. The workaround to this problem is to maintain a pool of threads. In contrast, goroutines are created and destroyed by the runtime and those operations are pretty cheap. The language doesn’t support manual management of goroutines.

https://blog.nindalf.com/posts/how-goroutines-work/
Nindalf How Goroutines Work Krishna's personal blog
More from @webapparch
  1. Aug 2, 2026У кого еще «перманентный психоз»? 🤪 - Смена роли: Раньше ограничением инженера была его с…
  2. Aug 1, 2026Document Review Agents Сейчас все документы, прежде чем читать самому, прогоняю через veri…
  3. Jul 27, 2026Продуктивность собирается из мелочей 🧠 Имплементация больше не боттл нек. Мое внимание -…
  4. Jul 23, 2026Интересный способ применить Ии в образовании : https://x.com/iPaulCanada/status/2079981184…
  5. Jul 20, 2026DeepSeek в 20 раз дешевле Антропика 💸 Стоит переходить? 🤔 На выходных потестил pi.dev в…
  6. Jul 19, 2026День удался !
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →