Skip to content

Commit

Permalink
[Gin] Add a warning about potential memory leak for CreateFunctionTem…
Browse files Browse the repository at this point in the history
…plate

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}
  • Loading branch information
mnaganov authored and Commit bot committed Mar 3, 2015
1 parent aa5cd16 commit 098ba6f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gin/function_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ struct Dispatcher<ReturnType(ArgTypes...)> {
// JavaScript functions that execute a provided C++ function or base::Callback.
// JavaScript arguments are automatically converted via gin::Converter, as is
// 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>
v8::Local<v8::FunctionTemplate> CreateFunctionTemplate(
v8::Isolate* isolate, const base::Callback<Sig> callback,
Expand Down

0 comments on commit 098ba6f

Please sign in to comment.