Re: debugging memory usage



Thanks Bart! You suggestions sound very useful, independently of my particular program. I'll try them & report on the outcome.

I've solved the overall problem by modifying the program such that it computes in a different way, which does not produce a memory exception on the examples I've tried.

Best regards,

Andrey


Bart Demoen wrote:
Andrey Rybalchenko wrote:
Dear group,

my sicstus prolog program, which implements some symbolic computations,
terminates with the exception resource_error(0,memory).
The behavior is reproducible, but takes about 10 hours to do so.

What is the best way to find out where the memory is consumed?

The "best" way might depend on how big your program is: if it not too big, I would do a visual inspection looking for left behind choicepoints, left recursion, and accumulating parameters that keep accumulating during 10 hours. I would also look for creation of new atoms/functors. If you know your program very well, you could do that on a larger program as well.

Another thing you could do: call statistics/0 when you get the
exception. Any memory area that has grown will show up there.
If you feel unsure about that, try to get out of memory with
the following program:

a([X|R]) :-
        X = [1,2,3,4,5,6,7,8,9,0,_],
        a(R).

a :- a, b.

d :- d.
d.

once with the query ?- a(_).
and once with ?- a.
and once with ?- d.
and look at the output of statistics/0 and which areas have become big.
Compare it to what statistics shows after your own program has run out
of memory. You might not have learned very much, but at least you might
know whether the overflow is because of term creation, choicepoints or
recursion depth.

If the program is not too big, put it on a website so that we can see
it.

Tell us about the outcome please :-)

Cheers

Bart Demoen
.



Relevant Pages

  • Re: debugging memory usage
    ... terminates with the exception resource_error. ... Any memory area that has grown will show up there. ... and look at the output of statistics/0 and which areas have become big. ...
    (comp.lang.prolog)
  • Re: How to troubleshoot bugchecks on my own?
    ... not a memory problem. ... From that exception record and context, ... execute the instruction - without a problem. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Strange sudden shutdown issue with CF app
    ... Phone devices are notoriously low on virtual memory right out of the box because the OEMs decide to put every little thing into its own DLL and then have 25 processes launched at boot. ... Chris Tacke, Embedded MVP ... We have created an app that basically connects to a web service gets data, then stores it locally on the device, and when a record needs to be modified/added the system first tries to connect the web server sees if its availible, if not then it stores in locally on the device until the connection comes back, now I noticed that if the device does not mess around with the data connection then the application sits nicely as long as its open, and never gets shut down. ... But again most of the time I get no exception at all but just simply disappears. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: error wince600 boot message after dowload PB6 OS to HW board
    ... I would suspect that you have a memory layout problem, either the bootloader is using memory that is clobbering the downloaded image in some way, or the memory layout in the config.bib is wrong. ... Old or invalid version stamp in kernel structures - starting clean! ... Exception 'Access Violation': Thread-Id=00410002, ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Strange sudden shutdown issue with CF app
    ... Phone devices are notoriously low on virtual memory right out of the box because the OEMs decide to put every little thing into its own DLL and then have 25 processes launched at boot. ... Chris Tacke, Embedded MVP ... We have created an app that basically connects to a web service gets data, then stores it locally on the device, and when a record needs to be modified/added the system first tries to connect the web server sees if its availible, if not then it stores in locally on the device until the connection comes back, now I noticed that if the device does not mess around with the data connection then the application sits nicely as long as its open, and never gets shut down. ... But again most of the time I get no exception at all but just simply disappears. ...
    (microsoft.public.dotnet.framework.compactframework)