1. A method of inferring heap invariants for program objects maintained by a program in heap memory, comprising: causing the program to execute over a period in an execution environment having a heap memory managed using garbage collection; creating meta data to track a set of invariants to be inferred about the program objects created by the program in the heap memory, wherein the invariants are properties of the program objects which do not vary during execution of the program; upon a vitality check of the program objects in a garbage collection pass and during the garbage collection pass: traversing objects in the heap memory to determine, for each object which is traversed, whether the object is reachable; for each object in the heap memory that is traversed, as the object is traversed to determine if it is reachable, checking whether the set of invariants to be inferred about the object remain satisfied, and updating the meta data based on results of the checking; producing data reporting the invariants satisfied by the program objects in the heap memory during the period of execution of the program; generating an annotated program, wherein generating the annotated program comprises writing static annotations to the source code for the program specifying the invariants reported to be satisfied by at least some of the program objects in the heap memory; compiling the annotated program with edits to the source code into an edited program; and reporting occurrences of anomalies in which the invariants are violated by the edited program in a period of execution of the edited program at least by comparing the invariants specified by the static annotations in the source code and invariants reported in the period of execution of the edited program.