5 ms·
I've often wondered this myself. Perhaps the right answer would be to benchmark and/or use the profiler. On the other handy, I have never really had a situatio
by Matt3o12_ 9y ago
I've often wondered this myself. Perhaps the right answer would be to benchmark and/or use the profiler.
On the other handy, I have never really had a situation where I had to pass a strict that was really big (more then 1MB).
Most of the time, big data structures are actually just slices, which use pointers to point to the memory address of the underlying array (as far as I understand).
So having sich big struct is rather unusual. Maybe it is possible to do with strings, though it would depend on how are strings implemented in go (I would guess they are just slices as well).
Furthermore, having big strings 1<x<50 MB) is rather unusual unless the strings can also become really big (1GB in which case you should not probably pass-by-reference or even better, buffer the string because arbitrary length strings can easily cause ram problems).
- echlebek 9y agoIn Go, strings are internally a header that contains a length and a pointer. The bytes of the string itself are heap allocated.