none
WPF textbox throwing OutOfMemory exception... RRS feed

  • Question

  • Hello,

    I am using a texbox in my appication to capture the log. But when I reach a certain point, it throws a system.outofmemory exception and crashes the app. How can I handle such a situation. I really need to show all the contents to the user as I cannot remove older contents. Is it possible that I save some of the older lines to a temp file? If yes, how do I do it and also at the end I should be able to hit a Save Button to Save all the contents to a text file at the specified location. So if I am transfering contents of the textbox to a temp file then how do I combine the whole log (from the temp file as well as the textbox) and save it to this new file? Also is it possible to remove the temp file everytime the OS is restarted?? 

    Any help will be greatly appreciated.

    Thanks!  

    Tuesday, October 12, 2010 3:41 PM

Answers

  • If the content is Really huge, it is better to go with RichText box control than a simple text.

    U can save the file content wilt RichTextBox.SaveFile() (check the method name)

     

    Tuesday, October 12, 2010 5:58 PM

All replies

  • hi sim9000

     

    either your app exceeds the maximum application size or your ram is almost full(check it with windows task manager).


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Regards, Alireza
    Tuesday, October 12, 2010 3:55 PM
  • Hi Khalili,

    Thanks for replying!

    Does this mean that such a scenario is not applicable to textboxes at all? Like you said even if one of the 2 things (mentioned above by you) does happen then what would I have to do to fix it in my app?

    Thanks again!

    Tuesday, October 12, 2010 5:44 PM
  • If the content is Really huge, it is better to go with RichText box control than a simple text.

    U can save the file content wilt RichTextBox.SaveFile() (check the method name)

     

    Tuesday, October 12, 2010 5:58 PM
  • hi sim9000

    you can write some code to show your log page by page, but if you really want to show it all together, check your process(windows task manager -> Processes) and see if you need to install more ram for your pc/laptop/...


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Regards, Alireza
    Wednesday, October 13, 2010 6:07 AM
  • Bet you're using string=string + newline + logtext? That won't last very long in terms of memory usage. Try using string.appendtext(newline+logtext). This should allow you to get to the full usable length of 2.7 billion lines.
    Saturday, March 17, 2012 9:31 PM