• 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.
  • Posts

    • Lifetime subscription to Mail Backup X gets price dropped by 72% by Steven Parker Today's highlighted deal comes via our Apps + Software section of the Neowin Deals store, where you can save 72% off a lifetime subscription to Mail Backup X Individual. For most individuals and organizations, emails are the most critical part of daily activities and communications. Some of us realize the importance of backing up emails only when critical emails are lost for some reason. Plan ahead and safeguard your mail data today with a robust and reliable mail backup solution. Mail Backup X is a one-stop solution for mail backup, archiving, email management & mail conversion trusted by 42,000+ business and home users worldwide. Backup from major mail clients. Apple Mail, Microsoft Outlook, Office 365, Microsoft Exchange, Thunderbird, Postbox Backup from mail services. Gmail, Outlook.com, Yahoo, Gmx.de, Office365, Microsoft Exchange, or any service supporting IMAP protocol Archive file viewer. Quickly search & view your emails from archives Highly compressed archives. Save up to 3x storage space Import almost any mail archive. Files like .pst, .ost, .mbox, .olk, .eml, .rge, and more Mirror backup. Cloud storage (Google Drive, One Drive, Dropbox, Pcloud or FTP) or USB drive Restore. Restore direct to the server account or a separate server account Migration. Move all mails onto a new account in Office365 100% privacy. Encrypt & secure your data with military-grade aes 256-bit encryption and your own private key, so it's only visible to you Top-notch premium support. Get help that you need from experts Good to know Plan: Individual Edition Length of access: lifetime Redemption deadline: redeem your code within 30 days of purchase Access options: desktop Max number of devices: 2 Only available to new users Version: 2 Updates included A lifetime subscription to Mail Backup X normally costs $179, but you can pick this up for just $49.99 for a limited time - that represents a saving of $129 (72% off). For a full description, spec, and terms, click the link below. Get Mail Backup X (lifetime plan) for just $49.99 (was $179) Use coupon code SAVE20 at checkout to get this product for an additional 20% off We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • I will believe it when it happens. iOS 18 was heavily rumoured to be a massive overhaul with visionOS glass style UI elements. Never happened. I don't even believe the x26 naming scheme is real either, feels more like an April fools joke *shrugs* I'll be happy to be proven wrong. However, till Apple themselves say it's so I will remain skeptical.
    • Nothing Phone (2a) hits a sweet spot: Is this mid-ranger the best value for your money? by Paul Hill Are you in the UK and looking for a smartphone with a standout design, solid display, good battery life, and smooth software? Then the Nothing Phone (2a) stands out as a solid mid-range option, especially considering it’s discounted 36% from £349 to £222. To clarify, this is the 12GB+256GB Nothing Phone (2a), not the weaker 8GB+128GB model. I’ll cover what’s included with this phone, but if you’re convinced to pick it up, be aware that this is marked as a limited-time deal so don’t sit on your hands. What the Nothing Phone (2a) delivers (and where it stands out) Powering the Nothing Phone (2a) is a mid-range Mediatek Dimensity 7200 Pro processor, 12GB of RAM with an 8GB RAM booster, and an advanced cooling system to boost game performance and longevity. In terms of battery life, the Nothing Phone (2a) packs a 5,000 mAh battery that will keep the device running for up to two days. When the battery does drain, you have 45W fast charging which will take 40 minutes to get you to 100% battery. On the back of the phone there is a 50 MP Main (OIS & EIS) camera as well as a 50 MP ultra-wide camera. On the front, you get a 32 MP camera. This phone tries to punch above its weight with the camera with features like Ultra XDR and Portrait Optimiser. The display is pretty good too, it includes a 6.7-inch AMOLED with 1,300 nits peak brightness and 120Hz adaptive refresh rate. This screen is ideal for gaming with its higher refresh rate and that cooling system I mentioned earlier will help it keep chugging along nicely. This phone came out in the first half of 2024, so you may be wondering what the software situation is. It initially shipped with Nothing OS 2.5 which is powered by Android 14, but this has since been upgraded to Nothing OS 3.0, powered by Android 15. Nothing has promised three major OS upgrades for this device, but one has been used up so expect Nothing OS releases based on Android 16 and Android 17 in the coming years. For those not familiar with Nothing OS, it has a strong reputation for being clean, smooth, and well-optimised, with little to no bloatware. If you’re coming from a brand like Xiaomi which packs its devices with bloatware and even ads, then the Nothing Phone (2a) should feel very clean. Finally, environmentalism has come more into focus over the last decade and while buying a second hand phone is best, Nothing has made decent efforts with this device by using recycled materials to keep the carbon footprint low. Should you buy it? At £222, the Nothing Phone (2a) is significantly reduced in price, making it a solid option for people looking for a mid-range device. If you like the unique design, clean software, good camera, and a strong battery life, then this device is definitely for you. The deal is marked as a limited-time deal and Amazon has marked it as an Amazon Choice suggesting that it’s a good phone to buy. It’s also at its lowest price, so you definitely aren’t paying over the odds. If you’re convinced, check the buying link below! Nothing Phone (2a): £222 (36% off) / MSRP: £349 This Amazon deal is U.K. specific, and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon UK deals page here. Get Prime, Prime Video, Music Unlimited, Audible or Kindle Unlimited, free for the first 30 days As an Amazon Associate we earn from qualifying purchases.
    • "It will have curved glass sides around the entire phone, even at the edges." Will it be just a collectible? I can't imagine myself having a glass phone. I'd gladly exchange glass back panel for plastic or aluminium on mine.
  • Recent Achievements

    • Week One Done
      Al_ earned a badge
      Week One Done
    • Week One Done
      MadMung0 earned a badge
      Week One Done
    • Reacting Well
      BlakeBringer earned a badge
      Reacting Well
    • Reacting Well
      Lazy_Placeholder earned a badge
      Reacting Well
    • Dedicated
      Epaminombas earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      477
    2. 2
      +FloatingFatMan
      274
    3. 3
      ATLien_0
      243
    4. 4
      snowy owl
      208
    5. 5
      Edouard
      182
  • Tell a friend

    Love Neowin? Tell a friend!