Skip to content

Instantly share code, notes, and snippets.

@jcschefer
Created September 12, 2018 20:55
Show Gist options
  • Select an option

  • Save jcschefer/d78208e6847d7b8b145b94893576df65 to your computer and use it in GitHub Desktop.

Select an option

Save jcschefer/d78208e6847d7b8b145b94893576df65 to your computer and use it in GitHub Desktop.
A Sample Tester for List Destructors
#include <iostream>
#include <string>
using namespace std;
#include "List.h"
int main () {
List* l;
int n = 0;
while(true) {
l = new List();
// this is about 3 GB worth of memory on my computer
for (int i = 0; i < 100000000; i++) l-> insertAtTail(2);
cout << "allocating large list for round " << ++n << endl;
// comment out the line below to see what memory leaks would look like
delete l;
cout << "deleted large list for round " << n << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment