- 5

Can you show me how to overflow heap memory using any language of your choice?

Use any language

27th Jul 2020, 8:52 AM
QX 99
QX 99 - avatar
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; }
27th Jul 2020, 3:13 PM
Ketan Lalcheta
Ketan Lalcheta - avatar