1. Memory: how much left?

I had thought that Dechesnes's function FreeXMS() (in memory.e) would
help me know how much memory I have left. My problem is that I have to
keep as much data in memory to speed up computations. However, when I
load just a little too much, Euphoria starts using virtual memory and
my software crawls to a virtual (!) halt: 70 seconds where 0.7 used to
do the job. Typically, I keep data sets loaded from disk as members
of a sequence, and I periodically remove from the sequence those sets
least accessed. Since they vary in size considerably I had until now
to take an educated guess (read: hit-and-miss) as to how many I
could fit without Euphoria using virtual memory. I discovered
memory.e, and thought my problems would be over. All I had to do
was call FreeXMS() regularly, and shrink the sequence of data sets
when memory became low. Alas, after shrinking, a call to FreeXMS
returns the same amount of free memory as before shrinking. Yet,
periodically shrinking my sequences prevents Euphoria resorting
to virtual memory. So, Euphoria must know something that FreeXMS
doesn't, or...?

Here is  a example:

include memory.e

sequence list
list={}
printf(1,"\nFreeXMS=%d",FreeXMS())
for i=1 to 50000 do
  list=append(list,rand(1000))
end for
printf(1,"\nAfter appending: %d",FreeXMS())

list={}
printf(1,"\nAfter list={}: %d",FreeXMS())

I am lost. All I want to do is avoid the use of virtual
memory. Is there any way of telling when Euphoria is
about to resort to virtual memory?

Thanks in advance.

new topic     » topic index » view message » categorize

2. Re: Memory: how much left?

Jacques Guy writes:

> Alas, after shrinking, a call to FreeXMS
> returns the same amount of free memory as before shrinking. Yet,
> periodically shrinking my sequences prevents Euphoria resorting
> to virtual memory. So, Euphoria must know something that FreeXMS
> doesn't, or...?

When you shrink a variable, Euphoria puts the free space
into a pool of storage that it can use in the future.
It doesn't try to return the space to the operating system,
thus FreeXMS won't report that more space is available.

> I am lost. All I want to do is avoid the use of virtual
> memory. Is there any way of telling when Euphoria is
> about to resort to virtual memory?

If you are running under plain DOS you can prevent
virtual memory (swap space) from being used with:

SET CAUSEWAY=NOVM

In general, I don't know of any good way of detecting
when Euphoria (or any other language) is using or is
about to use virtual memory. Under Windows, the operating system
manages the use of virtual memory. It's a good question though.
I suppose if you measure the time() that it takes to do some
repetitive task, and notice when the time starts to become
much worse, it might indicate that you were now starting
to swap pages of memory to/from disk.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu