v8 will clean the objects up if it/when garbage collects. It garbage  
collects when it thinks it is low on memory.

If programterminatiom happens first, the operating system will,  
naturally, reallocate those resources.

Sent from Alex's iPhone

On Mar 17, 2009, at 8:59 AM, MJ <[email protected]> wrote:

>
> Actually I had one small question you guys might be able to answer. If
> a user writes a JavaScript file, and has some JavaScript classes in
> there and is creating new class objects in his or her script, is it
> guaranteed that V8 will manage the memory for those objects and clean
> it up. These classes are not bound to any C++ classes they are classes
> defined in JavaScript.
>
> On Mar 17, 8:27 am, [email protected] wrote:
>> Ok, thanks you guys you have been a great help. I think I have
>> narrowed down the issue and so far my tests have been successful and
>> have not seen the crash (crossing fingers). Its great to know there  
>> is
>> a place to go to discuss issues on something that is not greatly
>> documented. Thanks again.
>>
>> On Mar 17, 2:40 am, Søren Gjesse <[email protected]> wrote:
>>
>>> The creation and handling of the objects for the function call  
>>> looks OK.
>>> Just make sure that the local handles are not used in C++ anywhere  
>>> outside
>>> the handle scope they where created in. Also make sure that the  
>>> boundFunc is
>>> valid that is stored in a handle in an outer handle scope or in a  
>>> persistent
>>> handle.
>>> Regards,
>>> Søren
>>
>>> On Tue, Mar 17, 2009 at 12:50 AM, <[email protected]> wrote:
>>
>>>> No I have not tried Debug mode yet, I will have to give that a try.
>>>> But while looking through my code, I was wondering about  
>>>> dynamically
>>>> creating V8 objects. There are many times I handle events and  
>>>> need to
>>>> dynamically create an object and call a bound method from the  
>>>> script.
>>>> As of right now I create a member in my class that is a v8::Handle<
>>>> v8::Object > and then when i need to I create a new object and then
>>>> setup the object to be called into script.
>>
>>>> All are being created under a new handle and context scope:
>>
>>>> v8::Local< v8::Object > obj = v8::Object::New();
>>
>>>> obj->Set( v8::String::New( "FieldName" ), v8::Object::New() );
>>
>>>> v8::Local< v8::Object > objField = obj->Get( v8::String::New
>>>> ( "FieldName" ) )->ToObject();
>>
>>>> v8::Handle< v8::Array > arr = v8::Array::New( cnt );
>>
>>>>        for ( unsigned int i = 0; i < cnt; i++ )
>>>>        {
>>>>            arr->Set( v8::Integer::New( i ),
>>>>                      v8::String::New( tagData[ i ].c_str() ),
>>>>                      v8::ReadOnly );
>>>>        }
>>
>>>>        objField ->Set( v8::String::New( field.c_str() ), arr,
>>>> v8::ReadOnly );
>>
>>>>  v8::Handle< v8::Value > argv[ 1 ] = { obj };
>>
>>>>        v8::TryCatch tryCatch;
>>>>        {
>>>>            boundFunc->Call( owner, 1, argv );
>>>>       }
>>>> Would you say this is the correct way to handle dynamically  
>>>> creating
>>>> objects to call into the script?
>>
>>>> On Mar 16, 1:06 pm, Søren Gjesse <[email protected]> wrote:
>>>>> Have you tried running the code in debug mode? V8 has a lot of  
>>>>> assertions
>>>>> which might fail and point you in the direction of the error.
>>>>> Regards,
>>>>> Søren
>>
>>>>> On Mon, Mar 16, 2009 at 7:03 PM, Stephan Beal  
>>>>> <[email protected]>
>>>> wrote:
>>
>>>>>> On Mon, Mar 16, 2009 at 6:56 PM,  <[email protected]> wrote:
>>>>>>> The only time I call SetAccessor is to create function  
>>>>>>> templates and
>>>>>>> bind C++ calls to them. Do you think this could happen during  
>>>>>>> runtime
>>>>>>> when creating an array in C++ and sending into script?
>>
>>>>>> It's theoretically possible, sure. v8 is quite fussy about  
>>>>>> certain
>>>>>> things. For example, calling Object::Cast(*myHandle) will crash  
>>>>>> if
>>>>>> myHandle is-not-a Object. In my experience, most of the
>>>>>> harder-to-avoid crashes happen right after main() exits, when  
>>>>>> certain
>>>>>> objects are trying to destruct after v8 has already gone  
>>>>>> through the
>>>>>> static destruction phase.
>>
>>>>>> As a test, try something like:
>>
>>>>>> myArray->Set( Integer::Cast(*myHandle) )
>>
>>>>>> where myHandle is-not-an Integer. It "should" (in my  
>>>>>> experience) crash
>>>>>> there. Are you using:
>>
>>>>>> myArray->Set( Integer::New(...), ...)
>>
>>>>>> or the former form? (The latter should, in theory, not be a  
>>>>>> problem
>>>>>> unless you just happen to use whatever number v8 reserves for
>>>>>> NaN(???).)
>>
>>>>>> --
>>>>>> ----- stephan beal
>>>>>> http://wanderinghorse.net/home/stephan/
> >


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

Reply via email to