Re: Program Memory Low - Select a task to close or increase progra

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Why don't you run the check before your program allocates some memory?

Also, take a look at this post:

http://blog.opennetcf.org/ayakhnin/PermaLink.aspx?guid=f1df04aa-99c0-4e2a-906d-6fcf0c4b0d59

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com | www.opennetcf.org


"Tsviatko Yovtchev" wrote:

> Yeah it is really not pretty :)
>
> The problem is that it is not guaranteed to detect the exact moment when
> the app runs out of memory. So, it would not prevent the app from
> falling into the same nasty loop I described in my first message. And
> that is definitely something I do not want my users to see.
>
> Erwin van Hunen wrote:
> > What about running the check for memory in a separate thread and have it
> > check at certain intervals?
> >
> > It's for sure not 'pretty' but you can you register some events and have
> > your thread invoke them the memory becomes critical.
> >
> > /Erwin
> >
> > Tsviatko Yovtchev wrote:
> >> Hi Erwin,
> >>
> >> Thanks for the quick reply. I've considered this approach, but the
> >> problem with it is that it is hard find out exactly when there is
> >> absolutely no more memory available. The garbage collector hits in at
> >> some point and increases the amount of available memory for one thing.
> >> So, I have to put P/Invoke calls to GlobalMemoryStatus before every
> >> allocation which will make my code tremendously slow.
> >>
> >> I was thinking more along the lines of some event or callback function
> >> that occur when there is no more memory, but I could not find anything
> >> of the kind.
> >>
> >>
> >> Erwin van Hunen wrote:
> >>> Hi!
> >>>
> >>> You will have use P/Invoke code to find out about available memory.
> >>> Check this out:
> >>>
> >>> http://msdn2.microsoft.com/en-us/library/ms172518.aspx
> >>>
> >>> /Erwin
> >>>
> >>> Tsviatko Yovtchev wrote:
> >>>> I've been putting my application(C#, .NET CF) through some stress
> >>>> testing when I encountered this pretty nasty problem.
> >>>>
> >>>> Basically, when the application runs out of memory I get the
> >>>> "Program Memory Low - Select a task to close or increase program
> >>>> memory" dialog window with a list of running tasks that I can close
> >>>> to choose from. My app, however is NOT listed there. So, if I close
> >>>> everything else and my app still needs more memory I keep getting
> >>>> instances of this dialog window with nothing to choose from until
> >>>> eventually the whole system crashes at which point I need to do a
> >>>> restart.
> >>>>
> >>>> So, it looks like I'll have to handle this problem inside my
> >>>> application. The problem is I could not find a way to
> >>>> programatically determine the amount of free memory at a given point
> >>>> of time. I also could not find any event that occurs when there is
> >>>> no more free memory which I could handle inside my app.
> >>>>
> >>>> Does anybody have any idea how I can handle this problem?
>
.



Relevant Pages

  • Re: vector::clear() vs. new() / delete()
    ... >I'm studying the behaviour of vector class and I I was amazed by the ... >strange use of clear. ... >method released all the memory allocated by the vector, ... The program allocates other memory for the ...
    (alt.comp.lang.learn.c-cpp)
  • VB.net Memory usage 20k app, 15MB memory?
    ... Is there anyway to reduce the amount of memory a VB.net program allocates? ... Just a simple windows form, with one button and a label, and all the button ...
    (microsoft.public.dotnet.languages.vb)
  • vector::clear() vs. new() / delete()
    ... I'm studying the behaviour of vector class and I I was amazed by the ... strange use of clear. ... Can it produce memory leakage? ... The program allocates other memory for the ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Maximum memory available in XP
    ... There's no simple answer since it depends on virtual memory fragmentation ... other memory your program allocates, how many threads you have (and when ... to allocate a single contiguous chunk. ...
    (microsoft.public.vc.language)
  • Memory manager behaviour on Solaris 8
    ... My question is regarding the memory manager and when the allocated memory ... In other words, if a program allocates about 10Mb then free them, I expect ... event after several hours the process memory size doesn't decrease. ...
    (comp.unix.solaris)