What’s all that Memory For? > 온라인상담

온라인상담

글로벌드림다문화연구소에 오신걸 환영합니다
온라인상담

What’s all that Memory For?

페이지 정보

작성자 Iesha Longstree… 작성일25-11-16 13:27 조회9회 댓글0건

본문

What’s all that memory for? Perhaps it’s for storing strings? If you truly need to make use of the memory on your pc with Go-actually use it, with gigabytes of it allotted-then chances are you'll pay a big penalty for the Go rubbish collector (GC). However there are things you are able to do about it. The Go GC checks what elements of the memory you've allocated are still in use. It does this by looking at all the memory for references to other pieces of memory. If you’ve allocated tens of millions of pieces of memory, then all that ‘looking’ necessarily takes some CPU time to do. So should you truly want to use the gigabytes of memory in your computer, you might want to be slightly careful about how you do things. How bad is it? Think about you may have a determined need to remember 100 million random 20 byte strings. What sort of overhead does the GC impose should you do that in a traditional manner?



photo-1659535958543-efbf6ac67f29?ixid=M3Here’s some code to allocate those strings. This makes use of about 3.5 GB of RAM. So what impression does this have on GC? Properly, one simple thing we can do to measure this is name the Go runtime to pressure GC, and measure how lengthy that takes. How long does that take? Oh. That’s quite a long time. Effectively, it’s quite quick for looking at a hundred million issues (about 7ns a factor). But burning 700ms of CPU time each time the GC runs is certainly edging into the realm of "not ideal". And if we run the GC again, Memory Wave Experience it takes roughly the same time again. 700ms of GC work each time the GC runs until we’re finished with these strings. How can we repair it? Fortunately for us the Go GC is so intelligent that it does not take a look at every bit of memory allocated. If it is aware of the memory does not include any pointers, it doesn't look at it.

댓글목록

등록된 댓글이 없습니다.