outof memory exception in webbrowser

Hi,

I am using webbrowser control of opennetcf to display html page in netcf 1.0. I am using webbrowser.documenttext method to display the html pages.Each html page have 5 to 7 images.If i load 10 pages one after another i am getting outof memory exception.So how to dispose images in webbrowser to avoid this exception. I tried using Gc.collect and it doesn't work.



Answer this question

outof memory exception in webbrowser

  • Hemant Pathak

    Hi,

    I re-worked my test application to have an XML file with HTML in nodes. When starting the application, I read in the XML file and create an XmlNodeList and then switch between the different "pages" using the InnerXml property of the various nodes. I have GIF and JPG images in a subdirectory of "My Documents" which I access with file://\My%20Documents\Images\filename.gif.

    Unfortunately, I still do not see any problem with memory usage or an OOM exception.

    Is it possible that the OOM condition is due to some other processing in your application

    -Chris



  • Fran431916

    Hi, I tried to reproduce this problem by building a project with a WebBrowser control and 10 different HTML strings, each referencing 10 images from a website. The images were GIF or JPG format ~128x128 pixels.

    "Navigating" back and forth between these different pages using DocumentText did not reproduce the problem, so I cannot comment directly on the error you are seeing.

    The bulk of the implementation of the WebBrowser control is in the platform (i.e. native code in WindowsMobile). Other than the original string you are putting into DocumentText, most of the memory consumed by the control is not being managed by the NETCF garbage collector.

    I would be interested in a concise repro case of your problem which might allow us to further investigate a solution.

    -Chris



  • Ilya_X1

    The below shown is the sample i tried.

    <node1>
    <html>
    <body>
    <IMG align="" width="200" height="200" src="file://\Program files\sample\1.jpg"/>
    <p>
    ..
    </p>

    <IMG align="" width="200" height="200" src="file://\Program files\sample\2.jpg"/>

    <p>
    ..
    </p>

    <IMG align="" width="200" height="200" src="file://\Program files\sample\3.jpg"/>

    <p>
    ..
    </p>

    <IMG align="" width="200" height="200" src="file://\Program files\sample\4.jpg"/>
    <p>

    </body>

    </html>
    </node1>

    <node2>
    <html>
    <body>

    <IMG align="" width="200" height="200" src="file://\Program files\sample\5.jpg"/>
    <p>
    ..
    </p>

    .
    .

    .

    The XML node (node1,node2,node3.....) consists of HTML tags.I am assigning HTML contents to webbrowser.document text based on XML node.For example, XML node1 loads jpg images from 1.jpg to 5.jpg to webbrowser.I am not using the navigate property of webbrowser.Instead of it i am navigating front and back based on values of XML node.

    When i navigate like this for 7 or 8 times i am getting OOM.The images that i am using are in KB. The total size of all the images are nearly 1.5 MB in desktop . But when i load it in webbrowser of ppc the memory is reduced by 10 MB suddenly.

    I am using HP hx2415 PPC with OS Pocket PC 2003 SE


  • Goh Wah

    are you reusing the same webbrowser control each time, and simply setting its text to new document text
  • JTai

    Yes, i am reusing the same webbrowser control each time.
  • steal

    It would also be helpful to know device and platform (e.g. PocketPC 2003 or WindowsMobile 5.0).

    -Chris



  • Jackslu

    Yes i tried netcf 2.0 webbrowser.But here also i am getting OOM
  • Tejas_Kishanwala

    Did you try using the .NET CF V2.0 WebBrowser control
  • pdurbha

    Hi Chris,

    How you are disposing the images that are loaded in webbrowser while you switch between different pages For example

    i am assigning page 1 as

    webbrowser.documenttext= <html> <body> contents 1 </body> </html>

    and switching to page 2 as

    webbrowser.documenttext = <html> <body> contents 2 </body> </html>

    i am asking how the images that are in webbrowser are disposed while moving to page 2


  • outof memory exception in webbrowser