>
>
>
Hi,

Do I get it right that unoptimized code is shared but optimize code is not 
(or shared partially or...)?

If closure is the root of all evil, will it help with sharing if I remove 
the closure completely? 

Like this:
```
function Machine(power) {
 
  this.enable = function() {
    this._enabled = true;
  };
  this.disable = function() {
    this._enabled = false;
  };
}

var machines = []
for(var i=0; i<10000; i++) machines.push(new Machine)
```


 

>
> When I create many objects new Machine like this
> ```
> function Machine(power) {
>   var enabled = false;
>
>   this.enable = function() {
>     enabled = true;
>   };
>   this.disable = function() {
>     enabled = false;
>   };
> }
>
> var machines = []
> for(var i=0; i<10000; i++) machines.push(new Machine)
> ```
>
> ...I see in Chrome Heap Profile that every object has 36 bytes for 
> function enable/disable.
> That is so even if the function code is actually longer.
>
> Do I get it right that V8 actually creates these functions only ONE time 
> and uses it for all machines?
>
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to