Idea about memory management. Game related.
AgentOrange
AgentOrange_member at pathlink.com
Fri Jun 2 15:43:32 PDT 2006
In article <e5q8sd$214f$1 at digitaldaemon.com>, Walter Bright says...
>
>The gc will pause all threads when it does a collection, even if those
>threads are in another language.
>
>Some thoughts:
>
>1) The gc will only pause threads it knows about. So you can create a
>thread that is unknown to the gc by calling the operating system thread
>creation APIs directly. However, if you do this, then those threads must
>not manipulate or reference any gc allocated data.
>
>2) Using C++ new or malloc is no guarantee of latency. Neither of them
>have any constraints on how long they take to call, and (due to
>fragmentation) can cause a significant pause.
>
>3) To deal with (2), professional game programmers I've talked to will
>"preallocate" all the data they'll need before running the task that
>cannot be paused.
>
>4) It is very important to realize that the gc will not collect at some
>random time. It will ONLY collect during calls to new. No calls to new,
>no collections.
>
>5) Therefore, to avoid pausing during critical times in the game, avoid
>calling new during those times. You can call malloc() instead if
>necessary. Calling malloc() won't cause the gc to run.
>
>6) Collection pauses can be minimized by running the gc collector during
> idle loops, such as waiting for user input.
Thank you Walter, this is all useful information. But what about array
operations? Should one avoid using D arrays as well?
More information about the Digitalmars-d
mailing list