views:

23

answers:

1

In our company we somehow got code to production which crashed(because Heap got corrupted somehow). Developers developed, after that testers had hands on it and later on it was released natural way(monthly release). Everything was fine till it crashed... We tried to investigate it and found many places where we could get a heap corruption... What could we do to prevent this stuff? Stricken our code reviews(we have it 4/5 all times and only 1 developer doing it without any help from the coder of it)? Change our politics for memory management only through smart pointers or something else? Any advise would be nice!

+1  A: 

Switch a managed language (C#, Java, whatever) if you can. If you can't:

  • Use RAII.
  • Be very clear about who owns each bit of memory.
  • Create objects on the stack wherever possible.
  • Use smart pointers in a consistent way.
  • Have your code reviewers watch out for the above points.
Thomas