Commit 6a0e4d30 by Brett Wilkins

Fixing up some memory leakage that's been reported. Still some more to track down.

parent 36e73203
...@@ -43,6 +43,7 @@ void MakeOldCallback(uv_work_t* req) { ...@@ -43,6 +43,7 @@ void MakeOldCallback(uv_work_t* req) {
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
node::FatalException(try_catch); node::FatalException(try_catch);
} }
delete ctx->source_string;
sass_free_context_wrapper(ctx_w); sass_free_context_wrapper(ctx_w);
} }
...@@ -98,6 +99,7 @@ void MakeCallback(uv_work_t* req) { ...@@ -98,6 +99,7 @@ void MakeCallback(uv_work_t* req) {
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
node::FatalException(try_catch); node::FatalException(try_catch);
} }
delete ctx->source_string;
sass_free_context_wrapper(ctx_w); sass_free_context_wrapper(ctx_w);
} }
...@@ -144,11 +146,23 @@ Handle<Value> RenderSync(const Arguments& args) { ...@@ -144,11 +146,23 @@ Handle<Value> RenderSync(const Arguments& args) {
ctx->options.output_style = args[2]->Int32Value(); ctx->options.output_style = args[2]->Int32Value();
sass_compile(ctx); sass_compile(ctx);
source = NULL;
delete ctx->source_string;
ctx->source_string = NULL;
delete ctx->options.include_paths;
ctx->options.include_paths = NULL;
if (ctx->error_status == 0) { if (ctx->error_status == 0) {
return scope.Close(Local<Value>::New(String::New(ctx->output_string))); Local<Value> output = Local<Value>::New(String::New(ctx->output_string));
sass_free_context(ctx);
return scope.Close(output);
} }
ThrowException(Exception::Error(String::New(ctx->error_message))); Local<String> error = String::New(ctx->error_message);
sass_free_context(ctx);
ThrowException(Exception::Error(error));
return scope.Close(Undefined()); return scope.Close(Undefined());
} }
...@@ -188,6 +202,7 @@ void MakeFileCallback(uv_work_t* req) { ...@@ -188,6 +202,7 @@ void MakeFileCallback(uv_work_t* req) {
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
node::FatalException(try_catch); node::FatalException(try_catch);
} }
delete ctx->input_path;
sass_free_file_context_wrapper(ctx_w); sass_free_file_context_wrapper(ctx_w);
} }
...@@ -234,11 +249,23 @@ Handle<Value> RenderFileSync(const Arguments& args) { ...@@ -234,11 +249,23 @@ Handle<Value> RenderFileSync(const Arguments& args) {
ctx->options.output_style = args[2]->Int32Value(); ctx->options.output_style = args[2]->Int32Value();
sass_compile_file(ctx); sass_compile_file(ctx);
filename = NULL;
delete ctx->input_path;
ctx->input_path = NULL;
delete ctx->options.include_paths;
ctx->options.include_paths = NULL;
if (ctx->error_status == 0) { if (ctx->error_status == 0) {
return scope.Close(Local<Value>::New(String::New(ctx->output_string))); Local<Value> output = Local<Value>::New(String::New(ctx->output_string));
sass_free_file_context(ctx);
return scope.Close(output);
} }
Local<String> error = String::New(ctx->error_message);
sass_free_file_context(ctx);
ThrowException(Exception::Error(String::New(ctx->error_message))); ThrowException(Exception::Error(error));
return scope.Close(Undefined()); return scope.Close(Undefined());
} }
......
This diff was suppressed by a .gitattributes entry.
This source diff could not be displayed because it is too large. You can view the blob instead.
var util = require('util');
var sass = require('../sass');
var fs = require('fs');
var bigScssStr = fs.readFileSync(require('path').resolve(__dirname,'large_test.scss'));
var numTestCases = 1000;
var numCompiled = 0;
console.log(util.inspect(process.memoryUsage()));
for (var i = 0; i < numTestCases; i++) {
sass.render({
data: bigScssStr,
success: function() {
numCompiled++;
if (numCompiled === numTestCases) {
console.log(util.inspect(process.memoryUsage()));
}
}
});
}
var util = require('util');
var sass = require('../sass');
var fs = require('fs');
var bigScssStr = fs.readFileSync(require('path').resolve(__dirname,'./large_test.scss'));
var numTestCases = 1000;
var numCompiled = 0;
console.log(util.inspect(process.memoryUsage()));
for (var i = 0; i < numTestCases; i++) {
sass.renderSync({data: bigScssStr});
}
console.log(util.inspect(process.memoryUsage()));
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