?
Solved

User.exe errors

Posted on 2001-08-14
9
Medium Priority
?
170 Views
Last Modified: 2010-05-02
My program is intermittently causing illegal page faults in user.exe.  Can anybody give me a hint on how to figure what in my program causes this?  And possibly how to replicate the problem and solve it?
0
Comment
Question by:omega_sword
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 2

Expert Comment

by:JanusFury
ID: 6385117
Most definitely related to an API call. Or to some component you're using, possibly.

Are you using any API calls that use Lib "User" or Lib "User32"? Also, are you running on Win9x, WinNT or Win2k? There's major differences between the three, but I'm guessing 9x because those errors don't happen much on NT/2k.

I suggest checking the variables you're passing to the API functions. You may be passing a Variable ByVal instead of ByRef, or vice-versa. Also, you could be sending a string, but specifying the wrong length.

I suggest pasting any code that runs often in your app. (Painting code, timer code, etc)

Also, make sure you're allocating and deallocating all your GDI stuff properly in your painting code, if you use any API to do painting you have to be careful. You ALWAYS need to deallocate:
hBrushes
hPens
hFonts
hDC's (ReleaseDC for DC's attached to hWnd's, DeleteDC otherwise)

If you add more info I can get more specific.
0
 

Author Comment

by:omega_sword
ID: 6385253
My program gets distributed to different users, so I'm not so sure on which Windows version the error actually occurs.

These are the API calls that I use in Lib "user32" or Lib "user":

FlashWindow
GetCursorPos
GetDesktopWindow
GetSystemMetrics
GetWindowDC
GetWindowLongA
GetWindowRect
MoveWindow
ReleaseCapture
ReleaseDC
SendMessageA
SetWindowLongA
SetWindowPos
SetWindowTextA

I don't know what you mean by mixing up ByVals and ByRefs, though.  I mean, you declare whether a parameter is a ByVal or a ByRef when you declare the API call, right?  And when you actually use the API call, you merely pass the values, right?  The declaration will determine what kind of parameter pass it is, right?

Regarding string length, I think the only API I use that has a string parameter is SetWindowTextA, and that parameter is declared simply as String, without any length specification.  Is this a problem?

I don't understand what pasting code that runs often in my app will accomplish?  I actually have something like that, a timer, but what should the code contain?

I only use hDC's from what you mentioned, I think.  I'll check them out.

Thanks.  Hope you can give me more info.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 6385277
User.Exe exceptions are almost always caused by a lack of free System Resources. This is a real problem on Win/9x machines since the system resource pools are LIMITED to only 64k (Win/NT does NOT have this problem).

The only thing you can do.. is load FEWER Graphical components / controls so that everything fits into the limited System resource space available. Please note.. that these are fewer components / controls for ALL RUNNING Applications.. (ie.. close ALL other unnecessary windows / programs.. of any running application to get more space).

In your own program.. I would seriously look at reducing the number of Graphical controls that you are using.
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 2

Expert Comment

by:JanusFury
ID: 6385285
I suggest keeping the number of controls down, period.
Control arrays use just as many resources (if not more) as normal controls, so I suggest exchanging comboboxes for sets of option buttons, etc. Also, graphical controls are definitely resource hogs. Same with UserControls, you wanna keep down the number of those onscreen at any time.
0
 

Author Comment

by:omega_sword
ID: 6385322
That's gonna be a problem.  Our GUI is filled with graphics.  All the forms have background images, buttons are actually image controls, that even change image when you mouseover.  But if graphics controls are the problem, how do graphics intensive apps, like Sonique, pull it off?
0
 
LVL 14

Expert Comment

by:wsh2
ID: 6385467
One trick is to use something like the Microsoft PictureClip Control (Project -> Components). In it.. you map in one huge picture.. and then you crop picture images out of it (rather then individually define them). Eg.

+---------------+---------------+
|               |               |
|               |               |
|               |               |
|               |               |
|        A      |       B       |
|               |               |
|               |               |
|               |               |
|               |               |
+---------------+---------------+
|               |               |
|               |               |
|               |               |
|               |               |
|               |               |
|       C       |       D       |
|               |               |
|               |               |
|               |               |
+---------------+---------------+

One big picture.. ie one set of Graphical resources.. that really contains 4 Graphic pictures A, B, C, D.

The only problem with the Microsoft Picture Clip control is that it can only handle bitmaps and it is somewhat limited in resolution.

Short of something like that.. you MUST make certain that whenever you are finished with a Graphic.. you MUST destroy it in order to recover its resources (keep your fingers crossed that the control you are destroying does NOT have a resource leak.. <groan>) AVOID Picture Boxes if you CAN (a real resource hog) and use Image Controls instead.

I want to remphasize.. that this is a Win9x problem.. the NT/2000 architecture allows for UNLIMITED resources. This System resource limitation has been in place ever since Win 3.11 (32k Resource limit for 3.11.. <sheesh>). Hopefully M$ will correct it in the future.
0
 

Author Comment

by:omega_sword
ID: 6385549
Okay, got that.  Basically just make sure to destroy graphics objects when done.  But when you unload a form, will the resources used for the background image be recovered automatically?  How about image controls on that form?

I remember using PaintPicture somewhere within the code and then have the form AutoRedraw = True...that eats up some resources as well, right?  How do you recover resources used then?

Another kicker:  I have a form that loads up several images.  Now, I create several instances of that form depending on user input, so several can exist at any one time.  Will resources used be multiplied by the number of instances even if I used the same graphics (from an imagelist control) over and over?  Will using PaintPicture be better instead?

Thanks for the quick responses.
0
 
LVL 14

Accepted Solution

by:
wsh2 earned 400 total points
ID: 6385658
But when you unload a form, will the resources used for the background image be recovered automatically?

YES. (As long as everything on the form is dereferenced.. a prerequisite for any object to be unloaded). When you (re)LOAD the form.. the background will appear as it did when you originally loaded it.

Will resources used be multiplied by the number of instances even if I used the same graphics (from an imagelist control) over and over?

If you load the same graphic into 5 different controls.. you use 5x System Resources. Its the number of Objects that counts.

Think of each picture as its own window on the screen. As JanusFury so correctly pointed out.. each window requires its own set of hBrushes, hPens, hFonts etc.. ergo.. its own set of System Resources (regardless of whether the window is visible or not). The picture in and of itself is just data. It is only when you place it into a "window" container that it starts sucking up the Resources the container "window" needs to be displayed.

LOADing and UNLOADing Form.. or LOADing and UNLOADing Control (Control Collection Add / Remove methods) objects with a MINIMALIST approach is what is called for in circumstances like this.. ie.. SWAP, SWAP, SWAP.. tit for tat.. easy come, easy go.. that kinda thing.

My best wishes are with you.
0
 

Author Comment

by:omega_sword
ID: 6385728
Thanks wsh2.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

718 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