Subj : [Q] Possible to share prototypes accross contexts ? To : netscape.public.mozilla.jseng From : "t o b e" Date : Thu Jan 29 2004 07:28 pm Hi, I have a DOM implementation using SM for a limited resource platform browser which uses prototypes to fake inheritance. Since JS_InitClass requires a context this implies that the returned protype is only valid for that context and that I would have to call JS_InitClass for each new context I create (in fact this is the case since destroying the context in my app causes the GC to collect the prototypes... is this correct behaviour or a symptom of a bug on my part ?). There are 83 'classes' in my DOM implementation so I'm a little concerned that just blindly creating all prototypes when I create the context might be somewhat wasteful of memory, particularly as most of them are likely not to be used for any given context. So.. a couple of direct questions: Are prototypes 'large' objects and should I even be concerned that I'm initialising 83 of them every time I create a new context (plus an associative array to map the context to a table of prototypes). and Is there a way to share prototypes amongst contexts if they *are* large enough to be of concern. and Would introducing a 'higher' global object to that currently used by each context and then only ever having one context throughout the applications lifetime seem like a workable approach (this is a browser, the current globals are windows on a 1-1 relationship with documents). Cheers, t o b e .