Click here to Skip to main content
15,917,793 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Horrid Memory Management Issue Pin
antlers11-Sep-03 9:39
antlers11-Sep-03 9:39 
GeneralRe: Horrid Memory Management Issue Pin
Dangleberry11-Sep-03 23:15
sussDangleberry11-Sep-03 23:15 
GeneralProblem handling pictures Pin
abhi197110-Sep-03 22:19
abhi197110-Sep-03 22:19 
GeneralRe: Problem handling pictures Pin
Dangleberry10-Sep-03 22:37
sussDangleberry10-Sep-03 22:37 
GeneralRe: Problem handling pictures Pin
abhi197110-Sep-03 22:51
abhi197110-Sep-03 22:51 
GeneralRe: Problem handling pictures Pin
Dangleberry10-Sep-03 22:58
sussDangleberry10-Sep-03 22:58 
GeneralRe: Problem handling pictures Pin
abhi197110-Sep-03 23:02
abhi197110-Sep-03 23:02 
GeneralRe: Problem handling pictures Pin
Dangleberry10-Sep-03 23:41
sussDangleberry10-Sep-03 23:41 
OK, we're starting to get somewhere now. If this is you OnPaint() or whatever draw function, there is no need to be keep loading the picture in. What seems to be happening is LoadImage is loading a handle to a resource each time this function is called, but it is never freed. With bitmaps this is vital because you will soon run out of memory. Detaching the handle is not enough to free the memory allocated to the handle. I would store the result of your LoadImage call as a member HANDLE (alongside bBitmap) in the class that calls this draw function. I would also separate the file loading code so when you click, perhaps a button, the filedialog is called, if the HANDLE is NULL it then simply allocates a new one using LoadImage, otherwise use Detach on bBitmap followed by DeleteObject on the existing HANDLE, before LoadImage on the new pic. This frees your draw code to concentrate on drawing, no monster leaks would occur because everything you use to draw is in memory and isn't changing (only time it changes is when you click THE button and choose a file). This is definitely where A monster leak would be occurring, perhaps it is THE monster leak Smile | :) .
GeneralRe: Problem handling pictures Pin
Jagadeesh VN11-Sep-03 4:51
Jagadeesh VN11-Sep-03 4:51 
GeneralRe: Problem handling pictures Pin
abhi197111-Sep-03 22:36
abhi197111-Sep-03 22:36 
GeneralSocket programming in Visual C++ 6 Pin
fahimtufaillara10-Sep-03 21:55
fahimtufaillara10-Sep-03 21:55 
GeneralRe: Socket programming in Visual C++ 6 Pin
R. Thomas10-Sep-03 22:11
R. Thomas10-Sep-03 22:11 
GeneralRe: Socket programming in Visual C++ 6 Pin
Jagadeesh VN11-Sep-03 4:58
Jagadeesh VN11-Sep-03 4:58 
GeneralMenu on Dialog not working Pin
Ph@ntom10-Sep-03 21:36
Ph@ntom10-Sep-03 21:36 
GeneralRe: Menu on Dialog not working Pin
Jagadeesh VN11-Sep-03 5:03
Jagadeesh VN11-Sep-03 5:03 
Generalcompiler errors - I am confused Pin
Slaru10-Sep-03 17:25
Slaru10-Sep-03 17:25 
GeneralRe: compiler errors - I am confused Pin
Joe Woodbury10-Sep-03 18:23
professionalJoe Woodbury10-Sep-03 18:23 
GeneralRe: compiler errors - I am confused Pin
Cedric Moonen10-Sep-03 20:15
Cedric Moonen10-Sep-03 20:15 
GeneralRe: compiler errors - I am confused Pin
PengFeidu10-Sep-03 20:12
PengFeidu10-Sep-03 20:12 
GeneralRe: compiler errors - I am confused Pin
Ph@ntom10-Sep-03 21:54
Ph@ntom10-Sep-03 21:54 
GeneralRe: compiler errors - I am confused Pin
Slaru11-Sep-03 2:22
Slaru11-Sep-03 2:22 
GeneralRe: compiler errors - I am confused Pin
David Crow11-Sep-03 3:11
David Crow11-Sep-03 3:11 
GeneralRe: compiler errors - I am confused Pin
Arthur Westerman12-Sep-03 2:14
Arthur Westerman12-Sep-03 2:14 
GeneralDisplaying Doubles Pin
fynox10-Sep-03 16:55
fynox10-Sep-03 16:55 
GeneralRe: Displaying Doubles Pin
Michael Dunn10-Sep-03 17:04
sitebuilderMichael Dunn10-Sep-03 17:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.