[Pkg-javascript-commits] [node-leveldown] 345/492: more memory leak work
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:16 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.
commit ca4a493af5ff187a1b971e203bc018165612cae5
Author: Rod Vagg <rod at vagg.org>
Date: Sat May 18 19:24:06 2013 +1000
more memory leak work
---
src/database.cc | 3 ++-
test/leak-tester.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/src/database.cc b/src/database.cc
index bf74015..07b6f9b 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -81,6 +81,7 @@ uint64_t Database::ApproximateSizeFromDatabase (const leveldb::Range* range) {
void Database::GetPropertyFromDatabase (
const leveldb::Slice& property
, std::string* value) {
+
db->GetProperty(property, value);
}
@@ -554,7 +555,7 @@ v8::Handle<v8::Value> Database::GetProperty (const v8::Arguments& args) {
v8::Local<v8::String> returnValue
= v8::String::New(value->c_str(), value->length());
delete value;
- delete property.data();
+ delete[] property.data();
return returnValue;
}
diff --git a/test/leak-tester.js b/test/leak-tester.js
new file mode 100644
index 0000000..0c1ac2a
--- /dev/null
+++ b/test/leak-tester.js
@@ -0,0 +1,52 @@
+const BUFFERS = false
+
+var leveldown = require('..')
+ , crypto = require('crypto')
+ , putCount = 0
+ , getCount = 0
+ , rssBase
+ , db
+
+function run () {
+ var key = 'long key to test memory usage ' + String(Math.floor(Math.random() * 10000000))
+
+ if (BUFFERS) key = new Buffer(key)
+
+ db.get(key, function (err, value) {
+ getCount++
+
+ if (err) {
+ var putValue = crypto.randomBytes(1024)
+ if (!BUFFERS) putValue = putValue.toString('hex')
+
+ return db.put(key, putValue, function () {
+ putCount++
+ process.nextTick(run)
+ })
+ }
+
+ process.nextTick(run)
+ })
+
+ if (getCount % 1000 === 0)
+ console.log(
+ 'getCount ='
+ , getCount
+ , ', putCount = '
+ , putCount
+ , ', rss ='
+ , Math.round(process.memoryUsage().rss / rssBase * 100) + '%'
+ , Math.round(process.memoryUsage().rss / 1024 / 1024) + 'M'
+ , JSON.stringify([0,1,2,3,4,5,6].map(function (l) {
+ return db.getProperty('leveldb.num-files-at-level' + l)
+ }))
+ )
+}
+
+leveldown.destroy('./leakydb', function () {
+ db = leveldown('./leakydb')
+ db.open({ xcacheSize: 0, maxOpenFiles: 10 }, function () {
+ rssBase = process.memoryUsage().rss
+ run()
+ })
+})
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git
More information about the Pkg-javascript-commits
mailing list