none
Memory allocation failure after using File open browser under Windows 7

    Question

  • Hi,

    I use the Silverfrost Fortran compiler to provide an interface to Windows.

    My app runs perfectly under XP-32 and Vista-32.

    But, under Windows7, (both w7-32 and w7-64) a call to allocate memory fails, but only if the app has previously used the file-open dialogue.  Specifically, using ProcessExplorer, I can see that my app has successfully allocated 980Mb if the file-open dialogue is bypassed, but it fails at 750Mb if the file-open dialogue has been used.  I'm not trying to grab large chunks of memory in one go (the failure occurs with a call to allocate 20Mb).

    Can anyone help?


    K

    Monday, June 18, 2012 8:30 AM

All replies

  • I use the Silverfrost Fortran compiler to provide an interface to Windows.

    My app runs perfectly under XP-32 and Vista-32.

    But, under Windows7, (both w7-32 and w7-64) a call to allocate memory fails, but only if the app has previously used the file-open dialogue.  Specifically, using ProcessExplorer, I can see that my app has successfully allocated 980Mb if the file-open dialogue is bypassed, but it fails at 750Mb if the file-open dialogue has been used.  I'm not trying to grab large chunks of memory in one go (the failure occurs with a call to allocate 20Mb).

    Can you supply a simple program (preferably a console application, and
    in C/C++) that reproduces this behaviour?

    Dave

    Monday, June 18, 2012 8:38 AM
  • Thanks, Dave, I'll try to isolate it down to a "noddy", but I'll have to arrange with a 3rd-party to do it (as I don't speak "C"!) so it may take a couple of days...


    K

    Monday, June 18, 2012 9:09 AM
  • I am writing to check the status of the issue on your side.

    What about this problem now?

    I searched on the internet, and use the OpenFileDialog and memory related keywords, but I cannot find any page discussed the similar problem.

    And I also cannot repro the same problem. 

    Once it failed to allocate the memory, is there any error code?

    Maybe you can help us dump the memory and share it to us through the "skydrive".

    You can ref my this tutorial content and links to dump the memory, and then keep the pdbs with your dump together.

    http://mikedoszhang.blogspot.com/2012/06/crashme-analysis-tutorial-1-breakpoint.html 

    Best wishes,


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us



    Thursday, June 21, 2012 9:31 AM
  • Hi,

    I'm still awaiting some feedback from the C++ programmer as to when he can do the small test program...


    K

    Thursday, June 21, 2012 9:38 AM
  • Thanks for you response!

    I will go on to research it.

    Good day!


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

    Thursday, June 21, 2012 9:57 AM
  • OK, I've got some C code.  I've put the source and compiled exe in my public skydrive folder, but I'm not sure  how to link to it? 

    Does this work?

    https://skydrive.live.com/#cid=C0546E02C66A1F60&id=C0546E02C66A1F60!121


    K

    Saturday, June 23, 2012 7:38 PM
  • You can use the skydrive as this.

    http://sdrv.ms/NqDQ0B

    This is the project I tried to created according to your code.

    But I have some places are not clear:

    windows_instance()

    and 

    strend(p)

    I'm not sure if my this demo can reproduce this issue, can you help us finished the demo and test if it can repro the same issue?

    Thanks!


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

    Monday, June 25, 2012 5:00 AM
  • Hi,

    I think, for the purposes of the test, you can put:

      ofn.hInstance = NULL;

    And leave the strend function commented out.

    On my W7-64 machine, I then lose 400Mb depending on whether I open the file dialogue or not...

    edit: I've posted a much simpler example of the problem: http://sdrv.ms/NqYrSw


    K


    • Edited by KennyTilley Monday, June 25, 2012 7:26 AM New simpler example provided.
    Monday, June 25, 2012 6:41 AM
  • After test so many times, it seems the that part is reserved memory.

    Use the 4M each time to allocate the memory, it makes the deviation seems lager.

    So I just use 4K, then 1K to test.(I don't know why the system("pause") cannot pause the application when I reduce the number to 4k, 1K. No problem, I just set a breakpoint before it and check the k value before the main method return.)

    I found it maybe allocate about 98M to be the reserved memory, maybe this part is for browse the content when files in the open file dialog in the system.

    To test, I also tested to use the MessageBox to replace the GetOpenFileName, it makes the "reserved" memory to be about 24M.

    I cannot find any document to research deeply to these phenomenon, but I think that part memory could be the system reserved memory for the controls usage.


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us




    Monday, June 25, 2012 11:36 AM
  • I agree.  Trying to allocate in chunks of 4Mb results in a loss of about 200Mb malloc-atable space, 4K ends up as about 100Mb loss. 

    Unfortunately, for my main app, my structures are up to 40Mb in size (they are related to datafiles that are at least that large), so to lose 400Mb seems excessive!

    I am surprised that that amount of memory isn't returned to the "heap" (or "stack" or wherever it comes from!) when the control closes.  Is there anyone at MS that can examine the problem in more detail?


    K


    Monday, June 25, 2012 11:54 AM
  • For more deeply research, since my experience seems not enough to track it, I will try to involve others senior engineer to see if they can give you help.

    Thanks for your patient!


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, June 26, 2012 4:51 AM
  • As far as I know, OpenFileDialog should have no memory leak. While because the dialog can be customized, there could be memory leak because of this. You can use http://technet.microsoft.com/en-us/sysinternals/dd535533 to check the free blocks, and see whether there is big enough one to hold your large memory allocation.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,
    Jacky Wu
    Microsoft Online Community Support

    Friday, June 29, 2012 9:07 AM
  • Hi Jacky,

    I''ve  posted two "mmp" files to my SkyDrive, one having opened the file browser, one without, when trying to allocate 40Mb blocks.  I don't know what they are supposed to show but one clear difference is the "total" memory mapped: (5796Mb with browser, 6116Mb without).  Also, the amount of "free" memory after the malloc has failed is different: (478Mb with browser, 157Mb without), which indicates that there is over 300Mb "free" but not "mallocable"?


    K



    • Edited by KennyTilley Friday, June 29, 2012 10:50 AM more details
    Friday, June 29, 2012 10:06 AM
  • Kenny, even there is totally 300M free blocks, it doesn't mean malloc can succeed for 40M allocation; it depends on whether there is single free block which is bigger than 40M.

    Can you let me know your address to visit your vmmap data file?


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,
    Jacky Wu
    Microsoft Online Community Support

    Monday, July 02, 2012 8:28 AM
  • http://sdrv.ms/QSCfVa


    K

    Monday, July 02, 2012 8:36 AM
  • I can't access the website. If no one can provide solution here, how about open a case to Microsoft? With a support case, a support engineer will request to check Inspect source code,and assist you to find the solution. I believe you can do what Inspect has implemented after having someone check the source code.

    Please visit the below link to see the various paid support options that are available to better meet your needs.

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Thursday, July 12, 2012 8:50 AM
  • try this link?

    https://skydrive.live.com/?cid=c0546e02c66a1f60&resid=C0546E02C66A1F60!140&id=C0546E02C66A1F60!140

    K


    K

    Thursday, July 12, 2012 9:29 AM