4 ms·
Hrm, I would think that if you were developing a game in a GC environment, where GC timing turned out to be a problem, you would get rid of dynamic memory alloc
by VikingCoder 8y ago
Hrm, I would think that if you were developing a game in a GC environment, where GC timing turned out to be a problem, you would get rid of dynamic memory allocation, and try to do everything much more like embedded system programming with fixed memory blocks...?
I suppose at the complexity of modern games that's simply not possible anymore...
- gameswithgo 8y agoYou can do that, and people do. However a GC language doesn't normally give you the flexibility of getting a block of memory and doing whatever you want inside it, instead you use things like object pools.
- pjmlp 8y agoSystem.Runtime.InteropServices.Marshal in C#'s case.
- louthy 8y agoAlso `fixed` in C# [1] Not used Span<T> and Memory<T> [2] in anger yet, but they also seem to be attacking the issue from the other end [1] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/fixed-statement https://docs.microsoft.com/en-us/dotnet/csharp/language-refe... [2] https://blogs.msdn.microsoft.com/mazhou/2018/03/25/c-7-series-part-10-spant-and-universal-memory-management/ https://blogs.msdn.microsoft.com/mazhou/2018/03/25/c-7-serie...
- VikingCoder 8y agoI consider object pools to be well within that family of problem solving that I'm talking about.
- jakewins 8y agoYou can allocate a block of memory with `ByteBuffer.allocate()` or, if you want it outside the JVM heap, `ByteBuffer.allocateDirect()`. You lose all the object/memory management features, though there are some projects around to provide struct-like APIs: https://github.com/alaisi/nalloc https://github.com/alaisi/nalloc