![]() |
|
#1
|
|||
|
|||
Request Help with losing resources.Back in the old days of Windows 95/98, I could see from Task Manager (I think) if my program was using up resources. Now under Windows Xp and Windows 2000 I cant seem to find that information.
My program displays the status (using colored Bitmaps for lights etc) of a machine. The program itterates at about 20Hz updating the screen. As far as I can tell I only change the Bitmaps when a change of state occurs. However, after 12 hours, the dialog is almost blank, and the bitmaps have gone. Also the system buttons (minimise, maximise) etc dont seem to work. Does anyone know how I can check to see if the program is using resources and if so how do I release them at 20 Hz? Regards |
|||
|
#2
|
|||
|
|||
Re: Request Help with losing resources.If you load your resources in the timer event (20Hz), then try to use some cases to check whether a resource file has been indeed loaded. Resources can’t just disappear from the program - probably you ran out of memory and they simply were not loaded, meaning, you have a memory leak and pretty big one.
Think where the resource files have to be released and check if that happens |
|
#3
|
|||
|
|||
Re: Request Help with losing resources.Thanks for the advice. We do have a memory leak which will hopefully be fixed by the company concerned later today.
If you think that the memory leak alone is the cause, then it should all work when this is sorted out. so fingers crossed. |
|
#4
|
|||
|
|||
Re: Request Help with losing resources.I have cleaned up the code and now use DeleteObject() before loading a new bitmap. This should improve matters. The memory leak will be dealt with by the 3rd party company supplying that particular library.
However, may I ask if I need to use DeleteObject() at program closure, or does the deletion of the CStatic object also delete any associated bitmap? Regards |
|
#5
|
|||
|
|||
Re: Request Help with losing resources.Well, you sure know how to ask a question. Next time try clarify a few things, which might be obvious for you but unfortunately not the rest of us, like what CStatic has to do with bitmaps.
Basically at program closure destructor is getting called. Now, if you handled releasing any memory in the destructor then I assume you don't have to call DeleteObject(), however it depends upon the CStatic purpose. If it is a subclassed class of a bitmap then destructor should do the trick, but if you are just using it for a position of your bitmap then deleting it won't do any good, meaning, you will have to release the resource "manually". |
|
#6
|
|||
|
|||
Re: Request Help with losing resources.Thanks for all the advice, the program has been up and running successfully now for more than 50 hours, and so I believe we have fixed the loss of resource problem.
In case others which to see how this was resolved : The key was to ensure that every time we wanted to change the bitmap image on a CStatic in the dialog we first deleted the current object. CPP / C++ / C Code:
Where GetBitmap()returned the previous bit map handle, (if there was one), which could then be deleted using DeleteObject(). Now we do not appear to be running out of resources. The memory leak by the 3rd party software is still there, so the resource problem was due only to the lack of deleting the objects. Once again, thanks for all the advice. |
Recent GIDBlog
Problems with the Navy (Officers) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Apache Webserver is being used a spammer to send request to other website | mintnovate | Apache Web Server Forum | 0 | 08-Oct-2005 03:02 |
| how to use resources, general info needed. | drewdaman | MS Visual C++ / MFC Forum | 1 | 14-Dec-2004 11:57 |
| Forum Speed | pcxgamer | GIDForums™ | 11 | 10-Jun-2004 08:07 |
| [You Decide] - Do we allow NEW threads with a list of links to resources? | JdS | GIDForums™ | 24 | 07-Mar-2004 13:19 |
| Hypermart request | Div | Free Web Hosting | 2 | 27-Oct-2002 13:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The