On Mar 9, 11:57 pm, Stephan Beal <[email protected]> wrote:
> That's not the way C++ does destruction. A C++ destructor may free
> resources, and dtors are not called at app exit if the objects are on
> the heap (which nearly all JS/Native wrapped objects are). That leads
> to db handles, file handles, etc. which don't get closed in a well-
> defined fashion (i.e. could lead to corruption).

Here's a silly example, but an example nonetheless:

Let's say i have a TempFile class which extends some File type but has
the feature that it deletes itself at destruction. In v8 that class
will sometimes be leaving temp files laying around. On Unix platforms
this can be worked around by deleting the file directly after opening
it (that's legal), in which case the handle is valid until the app
exits (and the filesystem may then free the space since it has no FAT
entry). On Windows we can't do that (we can't even rename an opened
file), so this isn't reliable from v8 on those platforms.

But the point applies more generally: arbitrary classes may allocate
arbitrary resources (even via a third party, such as some type of
object/Corba server), and not destructing may leave those resources
dangling in places outside the immediate application.

--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to