Traruh Synred

55 Reputation

3 Badges

8 years, 120 days

MaplePrimes Activity


These are replies submitted by Traruh Synred

@Carl Love I've discovered that I can subtract the list produced by kernelopts(memusage) and will write my own compare and 3rd column sum code. 

So far I've had no luck getting 'forget' to forget.

I'm considering re-writing the generator in c or c++. I gather I can call it from Maple somehow. Even w/o the Maple decay generator is very slow and I may have trouble getting the stats I need anyway. At the moment I don't see how to fix the leak.

I'd be better off doing the whole simulation in c++ or Fortran, but I no longer have access to the plotting and statistical tools I had at work.

@C_R I can't get 'forget' to work inside my procedures even when I put it in them. I did add 'forgetpermanent=true' but it didn't help.

I did get it to sort work for a simple loop calling 'sin' with multiple different arguments a bunch of times. Even in this case it only reduced the mem added by the loop, it did not eliminate it. 

I may force 'PickAngles' to use the same seed which will make things a little clearer and I might then be able to see a small effect. However, there's no big reduction that would eliminate my crashes. 

-Arthur

@Carl Love  Presumably if I use bytesused minus it value at the start of worksheet, that would work.

Not only is MemoryInUse() slow, but it behaves weirdly. When I call my procedure 'PickAngles' the 1st time MemoryInUse goes down!

@C_R  I tried the forget function with my procedure 'PickAngles'. It doesn't seem to work even if I explicitly forget the trig functions and whether I invokebefPick := MemoryInUse();
befPick := 14981316
picks := PickAngles(1.0, 1.0, 1.0, 1.3);
picks := [1.0436851512366284312, 2.3192032792429033422,

5.4636732233670413159]
NULL;
aftPick := MemoryInUse();
aftPick := 14940796
deltaPick := aftPick-befPick;
deltaPick := -40520

==>Bizzare -- calling PickAngles on 1st time reduce mem?


w/o forget
befPick := MemoryInUse();
befPick := 14946796
picks := PickAngles(1.0, 1.0, 1.0, 1.3);
picks := [1.3510991452015261644, 0.97624579892908323364,

4.2775509272694319973]
NULL;
aftPick := MemoryInUse();
aftPick := 15018384
deltaPick := aftPick-befPick;
deltaPick := 71588

With forgets
Threads[Sleep](10);
forget(sin); forget(cos); forget(arccos); forget(ProbDStarLNu); forget(PickAngles);
befPick := MemoryInUse();
befPick := 15209508
picks := PickAngles(1.0, 1.0, 1.0, 1.3);
picks := [1.1067741015117311538, 0.86676908974794681864,

1.2823048839358374206]
NULL;
aftPick := MemoryInUse();
aftPick := 15276092
deltaPick := aftPick-befPick;
deltaPick := 66584
==>Not much improvement..

Forget after PickAngles
befPick := MemoryInUse();
befPick := 15305216
picks := PickAngles(1.0, 1.0, 1.0, 1.3);
picks := [2.1058095475682443680, 1.3888900594897990436,

5.6476254693920000195]
forget(sin); forget(cos); forget(arccos); forget(ProbDStarLNu); forget(PickAngles);
aftPick := MemoryInUse();
aftPick := 15390624
deltaPick := aftPick-befPick;
deltaPick := 85408

Download ForgetTest.txt

it before or after PickAngles.

Here are some of my tries in the file I uploaded.

befPick := MemoryInUse();
                      befPick := 15305216
picks := PickAngles(1.0, 1.0, 1.0, 1.3);
    picks := [2.1058095475682443680, 1.3888900594897990436, 

      5.6476254693920000195]
forget(sin); forget(cos); forget(arccos); forget(ProbDStarLNu); forget(PickAngles);
aftPick := MemoryInUse();
                      aftPick := 15390624
deltaPick := aftPick-befPick;
                       deltaPick := 85408
 

@Traruh Synred I see that I have to name the procedure to be forgotten. If I specify my procedure and specify to forget sub procedures too will that do it or do have to specify every trig function I want to forget?

Do I have to apply it after each usage or once at the top?

@Carl Love MemoryInUse. kernoption(memusage) is faster. I'll see if I can extract the number from third column down (does it return a list? Well I'll soon find out).

MemoryInUse() is too slow for me to actually run long enough to get to the crash point. I gather from another answer that it may be trig functions remembering their values that fills up memory. I'm generating angular distributions and trig functions that get called a lot but never repeat.

Thanks!

@C_R  I do use sin and cos and arccos a lot. Rarely would I use the same argument. Indeed the whole point is to generate distributions of angles.I throw angles at random and pick one using the probability for those values. Indeed it is the picking routine that seems to use the most memory and it varies a lot from 'call' to 'call'. 

I'll try forget. Thanks.

@C_R Well I would not want to completely clear memory. I need the out put on the particle decay generation, which is returms with 'return result'.

@Carl Love I did discover MemoryInUse() on my own. I have a routine (particle decay generator) in a loop that keeps adding memory (beyond the few 4-vectors it's supposed to generate) every time it's 'called'. I thought its internal data would go 'out of scope' but it doesn't seem to. Maybe kernplots will give more insight into what's going on.

Thanks!

 

DEBUG() all caps invokes the debugger, but the bug button does nothing...?

Having got no useful suggestions, I worked one out for myself. Basically using plotv1,f2) where I construct v1 to be midpoints of bins I used for the data:

plotHist := proc (h, low, high)

local nhist, dx, xcenter, ibin, xBinCenters, thePlot;

nhist := Size(h, 2);

xBinCenters := Sample(0, 0);

dx := (high-low)*(1/nhist);

for ibin to nhist do

xcenter := low+dx*(1/2)+(ibin-1)*dx;

Append(xBinCenters, xcenter);

thePlot := plot(xBinCenters, h, style = point, symbol = cross, symbolsize = 80);

end do;

return thePlot;

end proc

Awkward but serviceable.

@sand15 Just a sketch of an example:

for ievent from 1 to nevent

GenerateEvent() (This generates from the array EventData. Here I assume it has only 1 track. 

                             but there could be many).

momentum=EventData[1]; theta=EventData[2]; phi=EventData[3];

end loop

I want to histogram each of the variables. With Histogram I'd have to insert each into it's own list in the event loop and then use Histogram for each of them. Thus looping over all three of them and making 3 potentially very big lists. If I bin them I can do that in the event loop as they are generated w/o any need to store a large number of floating point numbers. 

@mmcdara I know what Histogram does. It is not what I want to do. It indeed makes a histogram which it then stores in a very awkward form. It also does the loop over the variables one variable at at a time whereas I have many variables that need to be plotted in one 'event'. A list for each of them will likely be too big for Maple or my computer to deal with. 

Hence I want to make the histograms myself and plot them. dataplot makes a plot of a binned data, e.g.:

bins := [1, 2, 3, 4, 5];
                    bins := [1, 2, 3, 4, 5]
dataplot(bins, bar);

@mmcdara I know how to use Histogram, but I want to plot binned data! For one thing, a Histogram requires a large list of each data point and is thus a memory hog, and each time you make a histogram Histogram loops through the data for the quantity, and if you make it for a related quantity you have to loop again. 

Binning data avoids that. For another thing, it is awkward (I do know how thanks to Maple Primes) to get at the binned data stored as polynomials in a Histogram rather than as numbers in bins. And multiple variables can be used in a single loop over 'events' or 'tracks.' E.g., I might want to plot the momentum and the angles theta and phi for lots of tracks.

That's why I was asking specifically how to plot binned data, not asking how to make a Histogram plot which I do know how to do.

dataplot will plot binned data, but the axes are bin numbers and I want it to be theta or whatever variable I'm binning. 

@mmcdara Sure is complicated for such a simple operation on most histograms... Might be easier just to count it myself...

1 2 3 4 5 6 Page 4 of 6