?
Solved

error 7 out of memory

Posted on 2003-02-27
9
Medium Priority
?
209 Views
Last Modified: 2010-04-07
Hi!

I implemented an OCX containing 2 pictureboxes controls.
Then in a simple application (one form, one button), I load at starting this OCX:

Private Sub Form_Load()
dim i as long

for i = 1 to 20000
   load myOcx(i)
next i

end sub

The OCX loading does not finish well and I get 2 different errors according to the case:

debug:
the applicattion crashes with "error 7 out of memory"
and the number of OCXs loaded is 2374.

release:
the application crashes with "Unable to load OCX, OCX might be obsolete" => and this is not the case!

The memory of my computer is 512Mo and the application
use about 32Mo in debug and 15Mo in reslease.

1- Does anyone already had this problem?
2- Is there a limit of loaded controls on a form?
3- Is there a way to control the amount of memory allocated for the application?

Thanks!
Daniel

0
Comment
Question by:danielsnook
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 2

Expert Comment

by:DanAvni
ID: 8032383
a few pointers:
1. VB can not load an infinite number of OCX controls into a control array.
2. each picture box creates it's own Device Context (DC) and t's own Windows Handle (hwnd) this takes up windows memory and that might be what you are running out of.
0
 
LVL 2

Expert Comment

by:DanAvni
ID: 8032388
I would suggest creating instead of the picture box control the Image control which is lighter on system resources.

0
 
LVL 2

Accepted Solution

by:
DanAvni earned 200 total points
ID: 8032399
see
http://support.microsoft.com/default.aspx?scid=KB;en-us;q229756

for info on the maximal number of controls on a form
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:deighton
ID: 8033172
maybe if you tell us what you are trying to achieve with the 20,000 ocx, then someone might know another way of producing the same result.
0
 
LVL 18

Expert Comment

by:deighton
ID: 8033175
have you tried monitoring memory usage during the load of the ocx??
0
 

Author Comment

by:danielsnook
ID: 8033299
My application is a thumbnail viewer allowing to show pictures (JPEG, 150x100 pixels) in a directory.
Therefore, I need to load my thumbnails OCX then load picture thanks to the device context (DrawDibToDC WinAPI) of the picturebox of the OCX.

What do you mean by monitoring memory usage?
I kept and eye on memory during loading, and of course it increase, but when the app craches the memory used is lower than the max available on my machine.
0
 
LVL 1

Expert Comment

by:FunkyMeister
ID: 8200698
A better means would be to add a single image object and a single picture object and use the image object on your form (visible) and the picture object (hidden) to load each picture and size it accordingly, then paste the picture into the image and move onto the next one.  You can hotspot the thumbnail with mouse coords taken while it's hovering over the image.
0
 

Expert Comment

by:CleanupPing
ID: 8901035
danielsnook:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8983651
Moderator, my recommended disposition is:

    Accept DanAvni's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question