15

Just found this absolute 5 head, galaxy brain implementation in a piece of code which is called in a loop by a background scheduler which has performance issues.

There are 20+ properties, some which are recursively calling other properties with the same implementation style in this class.

Constant out of memory errors have been reported for this software, I wonder why...

Comments
  • 8
    Ah yes, the good old "I don't have to care about memory leaks, that's what the garbage collector is for"
  • 0
    "The spec said it should be sum, so I had to use Sum() instead of +"
  • 1
    I guess it works, just with a lot of unnecessary pressure on the gc.
  • 12
    My greatest fear is one day seeing my own absolute clusterfuck of a snippet on here.
  • 7
    @12bitfloat garbage collector driven development
  • 1
    @jeeper GCDD. Has a nice ring to it.
  • 1
    But we do OOP here!!!!!1111!!!!!
  • 0
    Cache calculated property values in shadow properties (discard them on state change or make the class immutable). The beast will run just fine and fast. You don't even have to touch the calculations themselves.
  • 0
    @jeeper still fits if you drop "collector".
  • 0
    @Oktokolo sad thing is a cache wouldn't help much as each property is only hit once or twice per run, but on many different instances of the objects.
  • 3
    @kwilliams WTF. How many 360 subscriptions can there be?!
  • 0
    @Oktokolo dunno what you mean by "360 subscriptions". 🤨
  • 0
    @kwilliams "CalculatedSubscription360Costs". And there are many objects needing to calculate that. For object counts in the hundreds, some extra GC exercising normally doesn't matter much. So you probably speak about orders of magnitude more... I wonder what the application is actually supposed to do.
  • 2
    It's a fairly simple CRM, but since the properties are all nested (some properties call other properties using the same construction whxih then also call other properties) even a few hundred records can cause thousands of array allocations per cycle.
  • 0
    @kwilliams Jesus Christ! That sounds horribly built. Gonna need a whole cluster just to calculate.
Add Comment