PowerBASIC Forums
  PowerBASIC for Windows
  Bitmaps Used In Menu's?

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   Bitmaps Used In Menu's?
Clay Clear
Member
posted December 01, 2001 09:16 AM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
Three days ago, I started getting this weird Windows aberration
where, if Windows is run for 5 or more hours continuously, and I
then try to run a Windows program, I get an error message
(to paraphrase) that states "...not enough free memory to run this
program..."

When this has happened, I've checked my memory status icon in the
tray (a program which I wrote), and the MINIMUM it says that I
had free (available RAM) was 130MB. I have used this same program
since I wrote it about 6 months ago, and don't believe that it
is all-of-a-suddenly returning erroneous data. Therefore, I
believe the error message is generated by my being out of
available Resources, not actual memory (RAM).

My OS is Win98SE, and I have NEVER had a problem of this nature
before.

The only changes I can coherently recall that were made three
days ago are: (1) I installed the newest video card drivers
for my video adaptor, which is an ATI Xpert 128 Rage 128. I got
the drivers setup EXE directly from the ATI homesite. (2) I
modified three of my system tray programs, which I always have running,
so that they use custom checked/unchecked BMP's for their
menu item checked states, then use SetMenuItemBitmaps with
those bitmaps, upon apporpriate menu selections.

So, about 8 hours ago, I uninstalled the new video drivers, and
reinstalled the old ones. The problem still occurred approximately
five hours later. However, it IS possible that the newest drivers'
UNINSTALL didn't do a clean uninstall, and some its software is still
in use by my Windows. I don't know any way to remedy this, other
than reFORMATting an reinstalling everything.

So, my actual question: can the custom checked/unchecked bitmaps
be constantly renewed by my programs, even though I have NOT been
making the menu selections that would actually change them? If this
is true, then that would most likely explain my problem, as the
constantly newly created hDC's would eventually make my resources
drop to a severely low limit. As it is now, the only places that
those programs destroy the bitmaps are in WM_CLOSE and in the
normal program termination WM_COMMAND processor.

If the answer to the question is in the affirmative, where in my
program would I need to destroy the bitmaps? In which MENU
command processor are they recreated by the program?

The three programs use hidden, MODELESS dialogs which exist
solely for the purpose of having a callback function to process
the MENU commands. The hChecked and hUnchecked custom bitmaps are
loaded either in WINMAIN, or in WM_INITDIALOG, depending on the
program - those are the ONLY places that they are loaded, so I
can't see how any of the programs could be reloading them.

I have gone back to using %NULL for the bitmap handles used by
SetMenuItemBitmaps. Will test that for the next 5-6 hours, to
see if the Windows aberration crops back up. I ran them that way
for a couple of months, with NO Windows errors, until 3 days ago.

While waiting for the results, any answers to this posting would
be MOST welcome.

Thanks in advance!

------------------
Clay C. Clear

Clay Clear's Software (Frames Only)
clayclear@home.com

IP: Logged

Michael Mattias
Member
posted December 01, 2001 09:20 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
Known problem with Win/9x.

O/S does not return deallocated memory to system pool correctly. When total system allocations during "up time" reach 2Gb, you are 'out of memory.'

Fix? Re-boot.

(Or go to NT or Win/2000, which do not have this problem).

MCM

IP: Logged

Clay Clear
Member
posted December 01, 2001 09:44 AM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
Michael,

Thanks for your prompt reply. However, I don't understand fully
how your answer would apply to my situation? As I stated in my
original posting, this problem had NEVER occurred before, until
starting 3 days ago. Did you mean that it applies because of the
two changes that I said I made 3 days ago? If so, how would I
correct it (other than my current attempt, which is to use %NULL
for the MENU's bitmaps when running SetMenuItemBitmaps)? Rebooting
every 5 hours I do NOT consider a viable option. Until now, my
Win98SE has been a VERY stable platform, with usually 5-7 days
between reboots, unless I run an app that actually eats up the
RAM, without having Windows release it.

Can you, or anybody else, give me a more detailed answer as to
WHAT can specifically be causing this error? I'm 99% sure that
it has something to do with the changes I made 3 days ago, otherwise
the problem would've cropped up a LONG time ago.

Thanks!

Regards,

------------------
Clay C. Clear

Clay Clear's Software (Frames Only)
clayclear@home.com

IP: Logged

Clay Clear
Member
posted December 01, 2001 11:20 AM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
ADDENDUM: I just recalled that one of my tray programs DOES
update one of its menu items every 10 seconds, when the TIMER
fires. And, that particular menu item does use my custom
bitmaps for its check states. It's not a critical timer operation -
it just automates updating the menu item based on the presence of a
Registry value and a certain directory. I'll disable the timer, and try it.
I'll also restore the custom bitmaps to the other two tray programs,
which ONLY update the bitmaps when I select them. But, now I've got to
wait ANOTHER 5-6 hours to see the result of these tests <sigh>

But, this leads to another question - if my Windows error is being
generated by low resources, WHY does it occur when using the custom
bitmaps, and NOT when using the DEFAULT Windows check state bitmaps?

The same program that refreshes its menu item every ten seconds used the
DEFAULT bitmaps until 3 days ago, and prior to that, I wasn't getting
that Windows error and I've been running the program continuously
as long as Windows has been up for the past 4 months.

Thanks in advance!

------------------
Clay C. Clear

Clay Clear's Software (Frames Only)
clayclear@home.com

IP: Logged

Brad D Byrne
Member
posted December 01, 2001 11:26 AM     Click Here to See the Profile for Brad D Byrne     Edit/Delete Message   Reply w/Quote
Clay, Just curious?

Are your custom bitmaps DIB's or DDB's?-----B

------------------
bbyrne100@aol.com

IP: Logged

Clay Clear
Member
posted December 01, 2001 11:45 AM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
I have LoadImage load them as DIB's (%LR_CREATEDIBSECTION). I
don't know offhand how my registered Photo Icons 2001 converts them, though. The
original bitmaps were JPG's, created with ImageViwer/32. I used
Photo Icons 2001 to convert them to BMP's.


------------------
Clay C. Clear

Clay Clear's Software (Frames Only)
clayclear@home.com

[This message has been edited by Clay Clear (edited December 01, 2001).]

IP: Logged

Michael Mattias
Member
posted December 01, 2001 12:19 PM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
If you think it is your program which is doing all the allocations, you CAN get around that.

I have a program which has the problem: I only need 2 or 3 Mb of memory at any one time, but I need it fairly often. What I did was this (and I think I posted this before, but darned if I can remember where):

At the start of the program, I create private heap with a size of 20Mb (your size is, of course, whatever you need).

Whenever my program needs to allocate these chunks of memory, I use HeapAlloc/HeapFree from that private heap.

It seems that while CreateHeap counts against your "total" of 2.1Gb, HeapAlloc/HeapFree do not; that is, memory allocated from a private heap is returned to the heap pool correctly, and it only costs you the value of the HeapCreate memory in terms of system usage.

Note that the PowerBASIC DIM/REDIM (array) are allocations, too; if you need to create lots of local arrays, your best bet is to allocate as above, then use DIM AT... the pointer returned by HeapAlloc. (This is actually how I came upon this Win 9x problem and solution).

MCM

IP: Logged

Clay Clear
Member
posted December 01, 2001 01:02 PM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
My Windows just aberrated again, this time after about 4 hours.
This is AFTER I had restored the three programs to the state they
were in before I modified them to use my custom BMP's. They ran
successfully in those states for 3-4 months, during which I
never had this particular Windows problem.

So am now convinced that my problem has been caused by shoddily
written video drivers. I think this because the problem started
in the same timeframe as when I installed the new drivers.
It is POSSIBLE, 'though unlikely, that the problem was caused
by other mods I made to some programs, mods that I can't recall
making, at this time.

Am going to reformat my HD and reinstall everything. I don't know
of any other means to "fix" the drivers problem. I had already
used Control Panel | Add/Remove Programs to remove the new
drivers, then reinstalled the old drivers. Apparently, either
the new drivers' UNINSTALL didn't do a clean & complete uninstall,
or there were some core components that it COULDN'T uninstall,
which my Windows is still using, and which still make the current
setup incompatible with the rest of my platform.

At any rate, MANY thanks to the people who replied to my original
posting. You may consider this topic "closed." If my problem
persists after the reinstallation, then I'll post a new topic,
asking for DETAILED troubleshooting help. I've got nowhere
else to turn, as the computer dealer where I bought my computer
has shut down, and there aren't any others in the local area that
I can turn to for help (I live in a VERY sparsely populated area )

Michael,

While the message you posted about the Heap functions may not be
germaine to my specific problem, after all, it was still VERY
informative and instructive, and I fully intend to use its info
when I start writing regular apps, instead of the "parlor trick"
programs that I've coded thus far. So, thanks.

------------------
Clay C. Clear

Clay Clear's Software (Frames Only)
clayclear@home.com

IP: Logged

Lance Edmonds
Member
posted December 01, 2001 02:49 PM     Click Here to See the Profile for Lance Edmonds     Edit/Delete Message   Reply w/Quote
Clay, if you use the Resource Meter app (that comes with Windows), what is happening to the free system resources leading up to the "low memory" condition?

ie, if GDI resources are dropping, chances are it is your app(s) that are the problem.

------------------
Lance
PowerBASIC Support
support@powerbasic.com

IP: Logged

Clay Clear
Member
posted December 01, 2001 03:48 PM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
Lance,

Thanks for your reply. It never even occurred to me to use the
Resource Meter to verify whether it's my GDI resources that are
being impacted. I guess I'm pretty braindead after messing with
the problem for the past (over) 48 hours.

I have gotten far enough in my HD reinstallation to set the Meter
to run at startup (i.e., my PB folders, including the tray programs
that run at Windows boot, are fully reinstalled). So, I'll finish
installing the vital hardware drivers, then reboot with the Meter,
and cease all reinstallation efforts until 5-6 hours, minimum have
passed. The recurring error ALWAYS occurred within 6 hours, max,
of each boot. It might not take that long, IF the Meter shows
definite changes before then.

It's also occurred to me that I might have a DIMM that's slowly
malfunctioning, such as a latent overheating problem.
Unfortunately, the thought didn't occur to me until after I had
already reformatted my C: partition.

At any rate, I'll be back in a few hours to post any observations
I make while running the Resource Meter, unless there are
dramatic changes before then.

Thanks again!

------------------
Clay C. Clear

Clay Clear's Software (Frames Only)
clayclear@home.com

IP: Logged

Clay Clear
Member
posted December 01, 2001 04:58 PM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
Ummmm, Lance, got a question for you, which I hope you answer
SOON, so I can move on to other endeavors, based on your reply: how long would you expect that I'd have to
monitor the Reource Meter before seeing changes, *IF* it's my programs
that are causing the resource losses (if the problem is indeed
that)? I've been checking it every 3 mins. for the past 30-40 mins.,
and the ONLY changes I observed in it were when I ran MSIE to
logon to here. Before I did that, the Meter display held steady at:

System: 90% User: 90% GDI: 99%

If my programs were causing GDI resources drops, wouldn't it seem
like it'd be reflected within those initial 30-40 mins., considering
that the programs are running continuously in the tray?


Thanks!

Regards,

------------------
Clay C. Clear

Clay Clear's Software (Frames Only)
clayclear@home.com

IP: Logged

Lance Edmonds
Member
posted December 01, 2001 05:10 PM     Click Here to See the Profile for Lance Edmonds     Edit/Delete Message   Reply w/Quote
Possibly - it completely depends on what the apps are doing... ie, you msy not have a problem until they start "working" - in idle state they may be content not to chew any resouces.

Anyway, this is just an idea to see if resources are a problem. It could just be a flaky install, and it could be some other app or service you have running.

In my experience, low memory conditions are rarely caused by Video drivers unless they are one of those recent "shared-memory" models - those work by using main DRAM as part of the video memory instead of relying on their own memory, and are hence cheaper/nastier than a "proper" card.

I've also seen everything from IE to Windows itself consume a whole heap of memory for no "obvious" reason.

That is, I think you need to move to a 2-pronged attack:


  1. Continue with the resource monitor under "typical" conditions
  2. Duplicate the app and resource meter test on another PC

This may help you pin it down, assuming it to be your app that is the problem.

After all, in the past 3 days, there have been a tremenous amount of Viruses sent around and you have no alluded to whether you have AV running... one of the symptoms of the BADTRANS virus is O/S instability.

And to be honest, the number of forum users that have emailed me viruses in the past few days is staggering. Some of you will have received my "note" by now and you will know who you are...

------------------
Lance
PowerBASIC Support
support@powerbasic.com

IP: Logged

Clay Clear
Member
posted December 01, 2001 05:56 PM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
Lance,

Thanks for replying promptly. I won't bug you or anybody else
anymore about this tonight. Rather, I am going to bed, as am in
desperate need of sleep. I will let the 'puter purr all night,
and see if the problem is there when I get back up. This SHOULD
be indicative, as the first time I discovered the Windows error
was also right after I had just gotten out of bed, after the computer
had been running without intervention for appr. 10 hours. The only
foreground app (display-wise) that was running was the screen saver.

The thought of a virus attack had occurred to me also, but I had
pretty much discarded that thought,a s the only e-mail I've downloaded to my
local machine in the past week-and-a-half was PowerBASIC's plug
for PowerTree ( got *2* of 'em in the same week!), and 3 from my
cable modem provider. The interesting thing about THOSE e-mail's was that I only
have 2 e-mail accounts with the provider; so, i have no idea why
I got the third e-mail - all 3 e-mail's were exact duplicates of each other,

One thing that I found out since posting my last message to you, which I
find to be interesting, is that I went back to ATI's website, and
reread their download page for the newest drivers for Win98. THIS
time, I mad enote of the fact that, to paraphrase, the page says:

"...for best multimedia applications and games functioning..." <- is a complete rephrase, but the general idea is there
"the following are REQUIRED to be installed FIRST before installing this new driver..."
"...Microsoft DirectX8.0a"
"...Updated <something-or-other>"

Well, when I installed the updated video drivers 3 days ago, I was running
DirectX 8.1. So, maybe the updated drivers aren't compatible with
DirectX versions higher than 8.0a? That would seem unlikely, as their
updated drivers that I downloaded appr. 1-1/2 years ago, which required
DirecteX 7.0 or higher, have successfully also worked on higher
versions of DirectX. However, of note is that the newest drivers
mention a specific version of DirectX, whereas the older drivers
said "...or higher..."...so, maybe *I* busted my OS by mixing
incompatible softwares...I realize that you said that you didn't know
of "real" video cards' drivers causing the memory errors that I were
getting, BUT, at the time, I hadn't told you of these new findings...

At any rate, I apologize for this windy posting...will cut it off at
this point...hopefully, my reformatting/reinstalling of my HD has
fixed the problem...

Thanks again for your valuable assistance!

------------------
Clay C. Clear

Clay Clear's Software (Frames Only)
clayclear@home.com

IP: Logged

Charles Dietz
Member
posted December 01, 2001 10:27 PM     Click Here to See the Profile for Charles Dietz     Edit/Delete Message   Reply w/Quote
Clay,

If the problem persists after reinstalling your OS, you might try running msconfig to remove all programs running in the background, and then add them back in, a few at a time, until the offending one can be isolated. Just a thought.

And if you suspect the ATI video drivers, maybe you could change the drivers to 'Standard VGA' supplied with Windows. Of course you will have only 640 x 480 resolution and 16 colors, but this would at least test if the problem is caused by the ATI drivers. Just another thought.

[This message has been edited by Charles Dietz (edited December 02, 2001).]

IP: Logged

All times are EasternTime (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | PowerBASIC BASIC Compilers

Copyright © 1999-2007 PowerBASIC, Inc. All Rights Reserved.


Ultimate Bulletin Board 5.45c