• 0

[VB6] Out of Memory error


Question

Hello gang,

This is one of those sad moments; I'm stuck supporting a VB6 app that loads an unlimited number of images (Medical app: Patient can have unlimited procedures, each procedure can have unlimited media (images and videos) and when a patient loads ALL of the images load. I recently affected a thumbnail so the load would be eased (really, the original developer didn't think it would be an issue to load unlimited original images! <sigh>) So, when the app loads enough images I get an "Out of Memory. Error Number 7" during an image control's LoadPicture function

I KNOW that there is not much I can do without moving this app to .NET and having Pages so that not all of the media load at once.

What I am asking is if anyone knows of an article that describes the limitations of VB6's memory usage. I have found some, but I am looking for ammo to back me up when I go to management about this issue.

If you happen to have an idea on how better to deal with this, I'm open to that as well... I just don't have my hopes up.

Thanks.

Link to comment
https://www.neowin.net/forum/topic/1053773-vb6-out-of-memory-error/
Share on other sites

9 answers to this question

Recommended Posts

  • 0
  On 24/01/2012 at 19:33, James Rose said:

I KNOW that there is not much I can do without moving this app to .NET and having Pages so that not all of the media load at once.

Are you sure of that? I haven't done any VB6, but I'd be surprised if it was that crippled that there was no way to implement a custom loading scheme for images. After all, the user cannot be viewing all images of all procedure at once, so there must be some way to limit the loading to what is currently viewable on-screen. It might be a lot of work though, something you'd get for free with, say, a virtualizing stack panel in WPF, so you could still make a convincing case that the app should be moved to .NET based on the potential time savings.
  • 0
  On 24/01/2012 at 20:37, Dr_Asik said:

After all, the user cannot be viewing all images of all procedure at once

You would think that they don't look at everything at once... but they do (in the current system layout) Changing the design to only load 5 procedures would be a big deal (really, REALLY badly design) Changing this pattern may be the only way to go.

I have been trying to get this app moved to .NET for 3 years. <sigh>

  • 0
  On 24/01/2012 at 21:09, James Rose said:

You would think that they don't look at everything at once... but they do (in the current system layout) Changing the design to only load 5 procedures would be a big deal (really, REALLY badly design) Changing this pattern may be the only way to go.

I have been trying to get this app moved to .NET for 3 years. <sigh>

You mean that there are enough images physically on-screen at once to cause an Out-Of-Memory error? I mean, how many images can you cram in a standard resolution... assuming ridiculously small thumbnails like 25x25 pixels, filling the entire screen, having no margins whatsoever, and a large resolution like 1920x1200, you get 3686 images, which should still be manageable, and that's a very far-fetched number.
  • 0
  On 24/01/2012 at 23:21, Dr_Asik said:

You mean that there are enough images physically on-screen at once to cause an Out-Of-Memory error? I mean, how many images can you cram in a standard resolution... assuming ridiculously small thumbnails like 25x25 pixels, filling the entire screen, having no margins whatsoever, and a large resolution like 1920x1200, you get 3686 images, which should still be manageable, and that's a very far-fetched number.

The thumbnails are down to 200 pixels wide and a related height. And yes, there are enough images to cause an Out of Memory, as I mentioned in my original post when the patient's chart loads ALL procedures load, and ALL media from each procedure load. (UG!) I initially thought it was a large image or some form of corrupt image that was causing the problem, but it is not. I can load the same 14mp image many, many times before the error occurs. (arg)

  On 24/01/2012 at 23:28, htcz said:

Explain to managment that this program has security bugs as VB support died in 2008.

If only that would work. I have told them that VB6 died a dozen years ago when .NET was released so... <sigh> To give you an idea on how messed up this is, the "back-end" is MS Access. It was originally built in 2003 and the CTO (who built this) had never heard of SQL Server Desktop Edition or SQL Server Express.

Thanks thought.

I believe I am going to have to tell them that there is no other way than to build anew

  • 0

Are you using bitblt to draw the thumbs or using a picture box control for every thumb nail ?

  On 24/01/2012 at 19:33, James Rose said:

Hello gang,

This is one of those sad moments; I'm stuck supporting a VB6 app that loads an unlimited number of images (Medical app: Patient can have unlimited procedures, each procedure can have unlimited media (images and videos) and when a patient loads ALL of the images load. I recently affected a thumbnail so the load would be eased (really, the original developer didn't think it would be an issue to load unlimited original images! <sigh>) So, when the app loads enough images I get an "Out of Memory. Error Number 7" during an image control's LoadPicture function

I KNOW that there is not much I can do without moving this app to .NET and having Pages so that not all of the media load at once.

What I am asking is if anyone knows of an article that describes the limitations of VB6's memory usage. I have found some, but I am looking for ammo to back me up when I go to management about this issue.

If you happen to have an idea on how better to deal with this, I'm open to that as well... I just don't have my hopes up.

Thanks.

  • 0
  On 25/01/2012 at 14:12, rbrucemtl said:

Are you using bitblt to draw the thumbs or using a picture box control for every thumb nail ?

An Image control is being used. While drawing the image might be an idea, it may not be realistic. But I will look into it. Thank you.

  • 0
  On 25/01/2012 at 13:57, James Rose said:

The thumbnails are down to 200 pixels wide and a related height. And yes, there are enough images to cause an Out of Memory, as I mentioned in my original post when the patient's chart loads ALL procedures load, and ALL media from each procedure load. (UG!) I initially thought it was a large image or some form of corrupt image that was causing the problem, but it is not. I can load the same 14mp image many, many times before the error occurs. (arg)

Yes, but my point is that you may not need to load images that are not currently, physically on-screen, even if they are on the page they may be off-screen (and you need to scroll to see them for instance). This is probably not a behavior you get out of the box with any VB6 control, but something that could be coded nonetheless.

Alternatively, you could rewrite it so that it loads a picture, creates the thumbnail, and then unloads the picture before opening the next one. That way you only keep the thumbnails in memory, and when the user requests to see a picture in full, then you load that picture specifically (and unload it as soon as he's done viewing it).

Both cases require a significant refactoring effort, but I don't see how it couldn't be just because it's VB6. Unless for some reason you cannot manually unload an image?

  • 0
  On 25/01/2012 at 19:00, Dr_Asik said:

Yes, but my point is that you may not need to load images that are not currently, physically on-screen, even if they are on the page they may be off-screen (and you need to scroll to see them for instance).

Ah, now I see your point. That might be an option, thank you.

I do feel that any actual answer is a short term solution, but that you kindly. I will give it some thought.

This topic is now closed to further replies.