Jump to content

How to allocate memory


photo

Recommended Posts

Hi,

 

I had a problem that "could not allocate enough memory " when I want to new 1000 Image.

 

I use the script like this : 

 

Image img = new Image[1000];

for(int i= 0; i < 1000; i++)

{

   img = new Image(directory);

}

 

but the log said it could not allocate .....bytes;

 

I understand it means the memory is not enough .

 

I need your helps.

Link to comment

Hi,

 

Don't forget to release allocated memory by delete operator. Otherwise you will have memory leak. Did you launch x64 build? x86 builds can use only 2-3 GB of RAM.

 

Could you please explain in more details why do you need to create at once 1000 Image in RAM? Is there any specific use case you are trying to achieve? 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Because in the project I need to use many pictures , if I new the pictures when I need , the frame will down ;so that I want to load them in the init

 

function, then the problem occur. 

 

It confused me is that my pictures are all 200*200 pixel , it size is only 10 ~20k, so 1000 pictures is only 20M memory .

Link to comment

Hi,

 

Don't forget to release allocated memory by delete operator. Otherwise you will have memory leak. Did you launch x64 build? x86 builds can use only 2-3 GB of RAM.

 

Could you please explain in more details why do you need to create at once 1000 Image in RAM? Is there any specific use case you are trying to achieve? 

 

Thanks!

Thanks for your reply, I test it again in another simple project and find it do well ,so it would be my project is too complexity .

Link to comment
×
×
  • Create New...