Skip to content

Instantly share code, notes, and snippets.

@JanneSalokoski
Created September 30, 2015 05:11
Show Gist options
  • Save JanneSalokoski/e8262bb8d71cc0f30f67 to your computer and use it in GitHub Desktop.
Save JanneSalokoski/e8262bb8d71cc0f30f67 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cmath>
int main()
{
using namespace std;
long long a[20] = {*a};
int i = 1;
while (i > 0)
{
a[i] = pow(2, 16) - 1;
cout << "a[" << i << "] <" << &a[i] << ">: " << a[i] << endl;
i++;
}
return 0;
}
$ g++ memleak.cpp -o memleak
$ ./memleak
a[1] <0x7fff279b9468>: 65535
a[2] <0x7fff279b9470>: 65535
...
a[19] <0x7fff279b94f8>: 65535
a[20] <0x7fff279b9500>: 65535
a[0] <0x7fff279b9460>: 0
a[1] <0x7fff279b9468>: 65535
a[2] <0x7fff279b9470>: 65535
a[3] <0x7fff279b9478>: 65535
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment