- 5
Can you show me how to overflow heap memory using any language of your choice?
Use any language
2 ответов
+ 1
May I know why you want to overflow ? It's not a desired scenario...
Still you can allocate large amount of memory on heap without de allocation being done... something like below in c++
#include <iostream>
using namespace std;
class Test
{
public:
long double d[100000];
void display(){}
};
int main()
{
try
{
for(int i = 0;i<1000000;++i)
{
Test* arr = new Test;
arr->display();
//delete arr;
}
}
catch(...)
{
cout << "bad alloc";
}
return 0;
}