tech
如何写出内存泄露的程序?
如何在 Go 中避免内存泄露?关注关闭文件、HTTP 响应体、字符串管理及 goroutine 使用。及时释放资源,避免循环引用,使用 defer 时要小心,助你写出健壮的代码!#GoLang #内存泄露
tech
如何在 Go 中避免内存泄露?关注关闭文件、HTTP 响应体、字符串管理及 goroutine 使用。及时释放资源,避免循环引用,使用 defer 时要小心,助你写出健壮的代码!#GoLang #内存泄露
tech
In the previous article, I implemented a simple RPC interface using the net/rpc package and tried out the Gob encoding that comes with net/rpc and JSON encoding to learn some basics of Golang RPC. In this post, I'll combine net/rpc with protobuf and create my
tech
Performance Implications of Memory Escaping in Go Programming
tech
RPC是远程过程调用的简称,是分布式系统中不同节点间流行的通信方式。是互联网时代的基石技术,Go语言的标准库也提供了一个简单的RPC实现,Go语言的RPC包的路径为net/rpc,本篇文章的目的是利用net/rpc 实现一个简单的RPC 接口,帮助我们拨开RPC 的迷雾。 对 net/rpc 而言,一个函数需要能够被远程调用,需要满足如下五个条件: * the method’s type is exported. * the method is exported. * the method has two arguments, both exported (or builtin) types. * the method’s second argument is a pointer. * the method has return
tech
在上一篇文章中,我用net/rpc 包实现了一个简单的 RPC接口,并且尝试了net/rpc自带的Gob编码以及JSON编码,学习了Golang RPC 的一些基本知识。本篇文章,我会将net/rpc 跟 protobuf结合起来,然后在了解一下如何使用Protobuf + 插件 生成 gRPC 的代码。 最后会尝试创建一个自己的protobuf插件来帮助我们生成代码,开始吧。 This article was first published in the Medium MPP plan. If you are a Medium user, please follow me on Medium. Thank you very much. 我们在工作过程中一定使用过gRPC + protobuf ,但是它们两个并不是绑定关系,
tech
Learn to implement a simple RPC interface in Go using the `net/rpc` package! 🚀 This article covers the basics and JSON encoding. Read more: https://dev.to/huizhou92/rpc-action-ep1-implement-a-simple-rpc-interface-in-go-1m96
go
Go编程中内存逃逸的性能影响
tech
Control memory manually through GOGC & GOMEMLIMIT
tech
How to Optimize Go Code Performance with Benchmarking
tech
原文:Avoiding high GC overhead with large heaps 当分配的内存量相对较小时,Go垃圾收集器 (GC) 工作得非常好,但是如果堆的大小较大,GC过程可能会消耗大量 的CPU。在极端情况下,它甚至可能无法完成任务(GC算法保证GC不会使用超过50%的CPU时间,如果超过这阈值,会导致内存泄露)。 有什么问题? GC的工作是确定哪些内存块可被释放,它通过扫描内存中分配的指针来完成这一任务。简单来说,如果没有指针指向某个内存分配,则可释放该内存分配。这种方法非常有效,但需要扫描的内存越多,所需时间就越长。 这是一个大问题吗? 有多严重?我们来揭晓!以下是 demonstrate 的小程序。我们分配 1e9 个 8 字节指针,即约 8GB 的内存。我们强制执行 GC,并测量它需要多长时间。我们会重复几次以获得一个稳定的值。还调用 runtime.
tech
Understanding Cache Penetration and Mitigation Strategies
tech
缓解缓存穿透的最佳实践