Program with memory consumption above 500MB because of many images

Asked

Viewed 73 times

0

Hello! I looked for solutions to my problem here and elsewhere and nothing helped. Codes and more codes to reduce memory and nothing...

I am a beginner in programming and do not notice my mistakes, we are here to learn :) My problem is this: I have a VB application with listbox listing several items. Each selected item loads a certain text for some Abels (to describe the item) and loads an image to a picturebox (each image is different) There are more than 1000 images all loaded from 2 Dlls. In the database.Vb file I created several cases. Each item selected in the listbox calls the corresponding image. EX database.Vb:

Case "Fulano"
                programa.idade.Text = "18" 'texto
                programa.picture.Image = dll.imgs.Fulano 'imagem

What happens is that when I compile, I click on any item of the listbox the program stops for 2 or 3 seconds (loading all images) and the use of memory passes to more than 500mb. So the program works normally but with the gigantic use of memory...

I know I could have created a database. But I don’t know how and I don’t know if it would help What would be the best solution for my case? There’s a way to make him upload image by image?

Maybe create an image-only database? Create a memory dump on the hard drive?

*PS: The ideal would be that the user did not have access to the images outside the program

  • 1

    What is probably occurring is that when loading the DLL all its 1000 images are being loaded in memory (hence the long time on first access and the high memory consumption). Whatever your solution, the ideal is you not keep All images in memory, but upload them as the user navigates the list. A trivial solution (not necessarily the best) is to maintain an internal list of image names and dynamically load them from a sub-folder in your executable’s installation folder.

  • 1

    Hello Luiz, thanks for the reply! I had already thought about it, however I would not like to leave the images out of some bank or dll.

  • The ideal would be that the user did not have access to the images

  • Not at all. But it wasn’t an answer, just a comment. As you added later, the ideal would be for the user not to have access to the images. I suggest you edit your question to make the problem more succinct and include this "ideal". It makes it easy to get more complete/correct answers. :)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.