Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

User.exe errors

Posted on 2001-08-14
9
Medium Priority
?
174 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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

926 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