VB6: A Minor Secret of Memory Management

I can not completely plunge into what happened in the VB6 program. This is on Win7-64 and Win10.

I wrote a proof of concept for Q and D to download and display 4K images (3640x2160). Each image occupies 24 MB of memory, so I โ€œknewโ€, based on a memory limit of 2 GB for 32-bit processes, I could upload no more than 80 images.

The system has 32 GB of memory, but everything that is not available to my program ... right?

Const nPix As Long = 80

Dim Pix(1 To nPix) as stdPicture  ' an OLE construct
For k = 1 to nPix
   Pix(k) = LoadPicture("next in folder")
Next

No problem, it takes a little time, but it works and uses the expected memory.

For grins, I increased nPix to 100, just to see how it happened. But this is not so. I tried nPix = 200, then 300. I still kept going, by then eating 8 GB of system memory. And no problem with:

PictureBox.PaintPicture Pix(300)

, , ? , ?

+4
1

, , - VB6 ...

0

Source: https://habr.com/ru/post/1669519/


All Articles