Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Object lifetime
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Determinism== Creation of an object is generally ''deterministic'', but destruction varies by programming context. Some contexts allow for deterministic destruction, but some do not. Notably, in a garbage-collection environment, objects are destroyed when the garbage collector chooses. The syntax for creation and destruction varies by programming context. In many contexts, including C++, C# and Java, an object is created via special syntax like <code>new ''typename()''</code>. In C++, that provides [[manual memory management]], an object is destroyed via the <code>delete</code> keyword. In C# and Java, with no explicit destruction syntax, the garbage collector destroys unused objects automatically and non-deterministically. An alternative and deterministic approach to automatic destruction is where the object is destroyed when code decrements the object's [[reference count]] to zero. With an [[object pool]], where objects may be created ahead of time and reused, the apparent creation and destruction of an object may not correspond to actual. The pool provides reinitialization for creation and finalization for destruction. Both creation and destruction may be non-deterministic. Objects with [[static memory allocation]] have a lifetime that coincides with the [[execution (computing)|run]] of a program, but the ''order'' of creation and destruction of the various static objects is generally non-deterministic.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)