[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Aug 2 15:07:49 1993 
Subject:Re: memory de-allocation 
From:Robin Popplestone 
Volume-ID:930802.06 

>> Sorry - I've never used the PWM.
> I wish I hadn't!

There would appear to be no reason for using the PWM these days unless you
don't have access to an X-server. POPLOG under X is a good tool (provided
you have enough machine to support it. Like all X-applications it requires
a minimum 16MB to run tolerably, more if possible.

> Thanks. I'll cut out the garbage collections. I had been advised that these
> were poplog's means to deallocate memory.

Garbage collection always happens, Setting pop_gc_copy to false just changes
the mode of collection.

> I'm afraid I have had to teach myself advanced image processing, and I have
> never come  across the  term  "memoisation"! I  will  explain how  I  would
> arrange the memory for this work if I was using C and Assembly.

Memoisation is a universal computational concept, and is not at all specific
to image processing. Sometimes called "function caching" it simply means
making a function remember the correspondence between argument and value for
argument/value pairs it has encountered.

Michie,D. 1968 ``Memo functions and Machine Learning, {\em Nature, 218} 19-22.

> I would have allocated blocks of ram  in a contigious segment, one for  the
> original image, and one or more using individual bit-planes on the byte  to
> hold the requisite masks, etc. I would  then assign a pointer based at  the
> start of the  first image,  and one  or more  offsets to  the masks  and/or
> results of filtering. This would give  a dramatic decrease in access  time,
> and the whole block could be easily deallocated.

> Is this what "memoisation"  means?
NO (see above)

> What are "poplog temporary properties" ?
See ref props. They support memoisation. Personally I use my own
memo-functions which use the system properties.

> I haven't  a  clue  as  to  how one  might  achieve  memory  allocation  or
> deallocation in poplog,

vars Pic = inits(n);   ;;; allocate n bytes of store

Is equivalent to the C

char * Pic = (char *) malloc(n);

The main difference is that POPLOG puts two words of dope information before
the block of store that is allocated.

It is actually better practice to have a specific vector-class however, rather
than using inits which allocates a string.

Explicit deallocation is a bad practice incorporated in most programming
languages because they lack a garbage collector. It leads to a large variety
of hard-to-trace programming errors.

> or  how one might assign  a pointer to such  memory

  Assignment in POP-11 does just that.

  Pic1 -> Pic2;

is an exact equivalent of:

Pic2 = Pic1; in C

provided Pic1 and Pic2 are pointers in C (and not structures).

> and utilize simple pointer  arithmatic in poplog.

Pointer arithmetic is bad practice in writing C, except for very special
purposes (e.g. writing a garbage collector). It should not be necessary
for image processing. With modern C compilers it can be LESS efficient than
array access.

> I  also have no idea  how one might include  C programs  into poplog, not
> having 6  months to  spend searching through help and reference files.

> I am  also extememly  reluctant  to try  using  low-level code  in  poplog,
> because I fear  it will only  open another  nest of problems  in having  to
> familiarise myself with the insides of poplog.

You do need a good understanding of what is going on. I do actually have
code to do image processing in POPLOG calling out to C and running under
X. It does edge finding, line-finding and some model-matching. You might
like a copy, or a copy of the low-level stuff I use...

Robin


Thanks for the useful tips on sectioncancel and sysgarbage.