Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: samples/hello-world.cc

Issue 1614763002: Sample running out of memory (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/hello-world.cc
diff --git a/samples/hello-world.cc b/samples/hello-world.cc
index 3b952d816b9b966a4f4e003c72dd1396883858d8..2b5340384a76880aa539ba6779403b14f39f5bd6 100644
--- a/samples/hello-world.cc
+++ b/samples/hello-world.cc
@@ -21,6 +21,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
virtual void Free(void* data, size_t) { free(data); }
};
+void FatalError(const char* loc, const char* msg) {
+ fprintf(stderr, "fatal error: %s: %s\n", loc, msg);
+}
+
int main(int argc, char* argv[]) {
// Initialize V8.
@@ -35,6 +39,7 @@ int main(int argc, char* argv[]) {
Isolate::CreateParams create_params;
create_params.array_buffer_allocator = &allocator;
Isolate* isolate = Isolate::New(create_params);
+ isolate->SetFatalErrorHandler(&FatalError);
{
Isolate::Scope isolate_scope(isolate);
@@ -49,8 +54,11 @@ int main(int argc, char* argv[]) {
// Create a string containing the JavaScript source code.
Local<String> source =
- String::NewFromUtf8(isolate, "'Hello' + ', World!'",
- NewStringType::kNormal).ToLocalChecked();
+ String::NewFromUtf8(isolate,
+ "var a = []; for (var x = 0; ; x++) { a.push(new "
+ "Array(104857600)); }",
+ NewStringType::kNormal)
+ .ToLocalChecked();
// Compile the source code.
Local<Script> script = Script::Compile(context, source).ToLocalChecked();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698