How can I prevent "zend_mm_heap corrupted" when adding Views programmatically?
There are several bugs reported to php.net about this error (search "drupal zend_mm_heap corrupted). Indeed it turned out to be a PHP bug with php 5.3.

I upgraded to php 5.4 and the error goes away. 

The issue is not necessarily Drupal related. However, it does seem to be related to how php includes and processes large files. In that respect, since Drupal can end up dealing with massive amounts of files and php data, this is probably the reason that many of the reported PHP bugs involved Drupal sites.

So, if you are getting this error, quite possibly you need to upgrade your PHP to 5.4