Re: Matheval ... the next step ...again

new topic     » topic index » view thread      » older message » newer message

Hi, Matt,

I really appreciate your responses.  

I'm taxing the system fairly heavily on this application I'm attempting to
build.  At least I think I am.

Then again, maybe not.  I've got about 1400 lines in my file that I use to build
controls (using newUIObj) and about 150 (so far) block files that are each
processed through Matheval when the system runs.  I'm expecting the number of
controls to double and the number of block files that will be accessed on any
given template being processed of something around 800 (when I get done - it is a
complicated set of documents).

In any event, this latest thing has me completely baffled, although I've
"solved" it for now (see below).  I'm not sure I can even do justice to
describing it...but here goes.

My latest block file has about 2000 characters in it.  Not much processing in
it, though, just a series of labels and goto's to append text to a sequence based
on the value of my controls (passed through to Matheval variables on a one to one
basis).

The issue is that I *think* I've discovered a memory leak.  Let's put it this
way, my memory usage climbs at about 100k every second until it gets to about 1.5
meg, then it starts ratcheting down to less than 100,000 and then it starts all
over again.  I didn't feel like letting it go to the point where the system
required restarting. It normally runs at less than 10k in memory (per the task
manager).

I've traced the cause to a single line at the very top of the newest BLOCK file
I'm developing.  I'm setting a variable to itself (in an effort to clear it). 
This is the first of my many block files where I've needed to clear the variable
before merely putting something in it.  That is, in everything else I've done,
there is always an assignment which takes place before any processing.  In this
latest case, there is no guarantee that an assignment will take place before I
need to add text to the sequence, so I'm attempting to clear it first.

The offending line is:

(mySeq := mySeq),

If I comment that out:

-- ((mySeq := mySeq),)

then the system runs fine.  No memory loss.  Program runs to completion in about
1 second.

Of course, commenting out that line means that my logic doesn't work because the
value of mySeq needs to be cleared, but I can clear that in my Euphoria code
before processing the file if I need to.

A little background, although it probably doesn't matter much to the issue.  I'm
attempting to build a template processor that will read an rtf file and
recursively fill in the information that the file lacks.  Each thing that the
file needs is associated with a name, which I conveniently make the same as a
control or a block file.  So, the program finds a name (let's say it is
txtGetInformationFromLastWeek) and it first looks for a control named that.  If
it finds it, it merely gets the text from that control and does a substitution. 
If it doesn't, it looks for a block file of that same name.  If it finds it, it
processes that block file and takes the result of that block file and puts that
into the template.  At any stage, either of these can have further tokens/names
in them and if they do, they will be resolved until none are left.

So, I know that since I'm running recursive routines there is a potential for
memory hogging and infinite loops.  I'm pretty sure I'm not creating any of them.

In any event, this latest block file attempts to clear the mySeq Matheval
variable and then, before it finishes processing, it (mySeq) is built up again
with the contents of what is expected to be the next substitution.

As mentioned above, I have reset the mySeq Matheval variable in the Euphoria
code with SetVar("mySeq",'"' & '"').  And it solves the problem.

Now, I can uncomment out:

-- ((mySeq := mySeq),)

and the program runs without the memory leak.  Of course, I don't need that line
now!

For me, there isn't anything to solve, but I thought I'd let you know what I ran
into.

Mike

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu