[webkit-help] Lifetime of ScriptState
tim.mahoney at me.com
Thu May 2 12:46:06 PDT 2013
At the moment, I never destroy ScriptStates. This is obviously wrong, so I need to know when and how to destroy them. Here are two solutions I can think of:
A.) Rather than pass around ScriptState* pointers, I can pass around OwnPtr<ScriptState>. When that OwnPtr<ScriptState> is no longer referenced, it will be destroyed. This means that thousands of ScriptState objects may be allocated and destroyed very quickly.
B.) Only create one ScriptState for each ExecState and store them in a HashMap<ExecState*, ScriptState*>. Then clear all the ScriptStates for a Document when the Document is destroyed.
Solution A seems the most correct to me, but I'm wondering if creating and destroying all those objects will slow everything down. Any thoughts?
More information about the webkit-help