// JP opened flex table

Click to See Complete Forum and Search --> : Memory allocation with new


Pravish
September 20th, 2007, 01:42 AM
Hi,
I am writing an application using Win32 api and using vc++ 6.0 under WinXp sp2.. I need to dynamically allocate a 9MB of space to store some .bmp image. I tried doing it with the 'new' operator but it seems to be failing since i m not getting the data. The space need to return me LPBYTE pointer.. can anybody suggest me an alternative to new operator and how can i ascertain that new is failing since its not giving me any exception!

thanks
regards

S_M_A
September 20th, 2007, 06:25 AM
Are you sure that new fails? 9Mb isn't that much so the risk of a failure seems minimal. Create a small compileable code snippet that reproduces the error and post it here, most likely it is someting else than an allocation failure.

Ali Imran
September 22nd, 2007, 10:23 PM
I had same problem few months back, so I started using windows specific memory allocation functions and they worked perfect for me.

See help for GlobalAlloc, GlobalFree.

Besides, you can use memory mapped files to read faster than ever.

regards

//JP added flex table