Commit 098ba6f5 authored by mnaganov's avatar mnaganov Committed by Commit bot

[Gin] Add a warning about potential memory leak for CreateFunctionTemplate

Whether to actually cache the template depends on the use case, so only
adding a warning in a comment.

BUG=463487

Review URL: https://codereview.chromium.org/974863002

Cr-Commit-Position: refs/heads/master@{#318889}
parent aa5cd166
...@@ -220,6 +220,11 @@ struct Dispatcher<ReturnType(ArgTypes...)> { ...@@ -220,6 +220,11 @@ struct Dispatcher<ReturnType(ArgTypes...)> {
// JavaScript functions that execute a provided C++ function or base::Callback. // JavaScript functions that execute a provided C++ function or base::Callback.
// JavaScript arguments are automatically converted via gin::Converter, as is // JavaScript arguments are automatically converted via gin::Converter, as is
// the return value of the C++ function, if any. // the return value of the C++ function, if any.
//
// NOTE: V8 caches FunctionTemplates for a lifetime of a web page for its own
// internal reasons, thus it is generally a good idea to cache the template
// returned by this function. Otherwise, repeated method invocations from JS
// will create substantial memory leaks. See http://crbug.com/463487.
template<typename Sig> template<typename Sig>
v8::Local<v8::FunctionTemplate> CreateFunctionTemplate( v8::Local<v8::FunctionTemplate> CreateFunctionTemplate(
v8::Isolate* isolate, const base::Callback<Sig> callback, v8::Isolate* isolate, const base::Callback<Sig> callback,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment