C# Excessive Garbage Collection - Large Strings, G2 pressure? -


i'm writing high-ish volume web service in c# running in 64-bit iis on win 2k8 (.net 4.5) works xml payloads , variety of operations on small , large objects (where large objects strings, on 85k (so going onto loh)). requests stateless, , memory usage remains steady on time. lots of memory being allocated , released per request, no memory appears being leaked.

operating @ maximum of 25 transactions per second, average call lasting 5s, it's spending 40-60% of it's time in gc according 2 profiling tools, , perfmon shows steady 20 g0 , g1 collections on 5 seconds, , 15 g2 collections on 5 seconds - meaning lots of (we think) premature promtion g2 data we'd expect stay in g0. read indicates excessive. expect system should able perform @ higher throughput 25 tps , assume gc activity preventing this.

the machines serving requests have lots of memory - 16gb - , application, under load, consumes @ 1gb when under load hour. understand bigger heap won't make things better, there spare memory.

i appreciate light on specifics (will try recreate conditions trivial application if time permits) - can explain why see g2 gc activity? should focusing on loh? people keep telling me clr's gc "adapts" load, it's not changing it's behavior in case and, unlike other runtimes, there seems little can tune (have tried workstation gc, there little observable difference).

microsoft decided design string class strings stored in memory monolithic sequence of characters. while works usage patterns, works dreadfully others.

one thing i've found helpful avoid creating instances of string whenever possible. if method used operate on part of supplied string, , in turn ask other methods operate on parts of it, methods should accept arguments specifying range of string upon should operate. avoid need callers of first method use subst construct new string method act upon, , avoid need have method call subst feed portions of string callers. in cases have used technique, creation of thousands of string instances--some quite large--could replaced zero.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -