Question

Somehow we got a LOT of ReaderWriterLockSlim in our code. Each of them takes 6K memory, so this has become a big issue.

As a quick fix, I'm looking for a less memory-hungry replacement. I'm trying a Joe Duffy's RW-lock, but it's not upgradeable and write-recursive (and is pretty hard to make it such).

Is there any other, more memory-light replacement?

Was it helpful?

Solution

Well, an obvious approach would be to use ReadWriterLock (sans Slim), which I believe is less memory intensive (but also less efficient in some scenarios).

OTHER TIPS

In case someone else needs a memory-lighter RW lock with the same semantics as ReaderWriterLockSlim:

  • upgradeable;
  • recursive;
  • lock belongs to a thread, so, for instance, recursive W-locks are OK, or R-lock from inside W-lock is OK;

the one from Mono source should be OK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top