cassandra c# driver memory leak -
using cassandra .net driver facing following issue: when inserting lot of rows parameterized inserts, application memory usage continuously grows:
class program { static cluster cluster = cluster.builder() .addcontactpoints(configurationmanager.appsettings["address"]) .build(); static session session = cluster .connect(configurationmanager.appsettings["keyspace"]); static int counter = 0; static void main(string[] args) { (int = 0; < 50; i++) { new thread(() => { while (true) { new person() { name = interlocked.increment(ref counter).tostring(), id = guid.newguid(), data = new byte[4096], }.save(session); } }).start(); } console.readline(); } } class person { public guid id { get; set; } public string name { get; set; } public byte[] data { get; set; } public void save(session session) { stopwatch w = stopwatch.startnew(); session.execute(session.prepare( "insert person(id, name, data) values(?, ?, ?);") .bind(this.id, this.name, this.data)); console.writeline("{1} saved in {0} ms", w.elapsed.totalmilliseconds, this.name); } }
according created memory dump managed heap contains huge amount of small byte arrays (most of them being generation 2), traced cassandra driver's byte conversion methods (invconvert*) in internal typeinterpreter class.
do have advice or ideas how rid of issue?
for else runs this. having memory problems when creating lots of cassandra.isession
s though disposing correctly via using
statement. changing code reuse single isession
seems have fixed it. don't know if best solution.
Comments
Post a Comment