|
ash_hdr wrote: So I want to know the memory usage of CreateDIBSection() Task manager will show you the usage of your application. If it keeps growing then you know it's leaking memory.
Veni, vidi, abiit domum
|
|
|
|
|
I already tried task manager to find the memory leak but not able to find it.
But it will be helpfull if i can get to know the memory which CreateDIBSection is consuming everytime it is getting called. Event though DeleteObject() is getting called at appropriate place but i just want to know the hole which is getting created in memory after each usage.
Thanks
|
|
|
|
|
ash_hdr wrote: I already tried task manager to find the memory leak but not able to find it. Task manager won'y help you find the leak, but it will give you an indication of the memory that is being used by your application, and whether it keeps growing all the time.
ash_hdr wrote: if i can get to know the memory which CreateDIBSection is consuming everytime it is getting called. That information is not readily available as it is internal to Windows.
Veni, vidi, abiit domum
|
|
|
|
|
Actually I tried all those things and event some tools also i tried but didn't get the expected results.
How much memory will the ppvBits takes in CreateDIBSection.
|
|
|
|
|
ash_hdr wrote: How much memory will the ppvBits takes in CreateDIBSection. No idea, but you could probably work it out by examining the documentation[^]
.
Veni, vidi, abiit domum
|
|
|
|
|
What is the point of the initBitmapInfo function? It creates a (I assume new) BITMAPINFO structure, initialises it with some values, and then returns without doing anything with it. That looks like a memory leak to me, depending on what getBitmapInfo is doing.
Veni, vidi, abiit domum
|
|
|
|
|
The variable which getBitmapINfo is getting a class member variable, so there is no memory leak there.
|
|
|
|
|
That's certainly not obvious from the code, nor is it obvious that this is part of some class. I would hate to be the poor developer who has to maintain this.
Veni, vidi, abiit domum
|
|
|
|
|
Sorry that's my fault. While pasting the code i removed that information.
|
|
|
|
|
ash_hdr wrote: While pasting the code i removed that information. Why? It really would help you much more to post the exact code that you have trouble with.
Veni, vidi, abiit domum
|
|
|
|
|
The CreateDIBSection call looks fine to me except that the last parameter is ignored according to the docs so you could pass there a 0.
|
|
|
|
|
But anyway this should not cause any issue. Is the height and width which i am passing is more and the bitmap is consuming a lot of memory? This function is getting called lot of times in my application.
|
|
|
|
|
You can calculate the memory needed by the dibsection and you should be able to track the memory allocation in your program. Put in some diagnostic code: When this createdibsection fails then run the diagnostic code that gets the available free memory and so on. Getting the free memory may not be the best diagnostic as sometimes the OS lies (for many reasons) and the available memory may be available only as fragmented small pieces. maybe a good diagnostic could could try to perform a malloc with approximately the size of the image (maybe a bit more, for example twice the size of the image). If this malloc fails then you probably went out of available memory. Use your creativity, these were just some stupid things I would try first...
3*6000*4000 == 72000000 bytes ~ 72megs. If you allocate 72 megs chunks rapidly you can exhaust even 1 gig of memory quite quickly...
|
|
|
|
|
Hi,
If you mean to say that if width = 6000 and height = 4000 and considering 3 bytes per pixel on every call createDIBSection is consuming 72 mega bytes then i feel this is the place which is causing memory fragmentation. Is my understanding correct?
|
|
|
|
|
I'm not saying that memory fragmentation is the problem. I don't know what the problem is. Let's try to find that out!
|
|
|
|
|
I am asking about the calculation i.e 72 MB for each CreateDIBSection call.
|
|
|
|
|
Rather than repeating the same question over and over, would it not be better if you acted on some of the advice you have been given? We do not know the exact amount of memory that is being used, and the best estimate is the one you have been given. It is up to you to do some logging/debugging of your application to find out what is actually happening when the code runs, and how much memory it is consuming.
Veni, vidi, abiit domum
|
|
|
|
|
Exactly!
|
|
|
|
|
Amazing how many people belieive that we CPians have some "magic bullet".
Veni, vidi, abiit domum
|
|
|
|
|
An even worst case scenario (not this one) when they think we can read their mind along with their unposted source code so we can put together a ready-made solution they can just copy-paste from the forum post into their IDE... I love this when coupled with some rocket engineering problem without math/physics knowledge!
Solving and debugging this problem is just basic memory examination as a first step, I really don't understand what takes so long... Maybe some lazyness??? Some periods of the development are really boring even in case of the best hobby projects...
|
|
|
|
|
Post the exact function call and describe the value of incoming parameters if possible.
|
|
|
|
|
6000 x 4000 x 3 = 72,000,000 bytes. or ~68MB.
|
|
|
|
|
I have an SDI application that uses a CFrameWndEx main window and has several CDockingPane 's inside of it.
The problem is that when I choose to create a new document, the Framework automatically resets the size of the CFrameWndEx to some fixed value that is stored somewhere (I don't know where.)
How can I disable this "feature?" I want the frame window to remain the same size when a new document is created.
EDIT:
The solution was to remove the call to ResizeParentToFit() in the view's OnInitialUpdate() .
The difficult we do right away...
...the impossible takes slightly longer.
modified 26-Aug-13 0:11am.
|
|
|
|
|
Even though Visual Studio 2010 and Visual Studio 2012 use the same file extension (.sln) for their solution files, somehow the File Explorer is able to assign them different file icons.
One of them says "10" and the other says "11".
Does anyone know how the File Explorer knows the difference between the two?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
How to Create Icon Handlers[^]
I guess this is the key for VS: HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln
The icon handler of visual studio is parsing the first 1-2 lines of the sln file if I remember right, the line that seems to be a comment is also used by the handler!
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
|
|
|
|