Can you show me how to overflow heap memory using any language of your choice? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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
1 Answer
+ 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