Thanks! This is what I wanted to know. It is especially helpful to
understand that having records with different arities can have an impact.
How much space does each arity structure take?
Irene
Date: Mon, 26 Sep 2005 08:48:08 +0200
From: Raphael Collet <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
Subject: Re: memory efficiency of records
To: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
Content-Type: text/plain; charset=us-ascii; format=flowed
Irene Langkilde-Geary wrote:
> How memory efficient are Mozart records? I'm using a C++ program that
> takes a 250M data file as input and builds a tree structure in C++ that
> occupies over 1G RAM when complete. Would it be even close to the same
> size if I recoded the tree-builder in Mozart, or should I stick to C++?
They are memory efficient. An Oz record of width N occupies a block of
N+2 pointers in memory. The two extra pointers are for the label and
the arity, which are stored separately. The objects describing arities
are never duplicated.
The overhead of the arity might be problematic if all those records have
a different arity. But otherwise, there is no contra-indication. Note
that tuples are slightly more efficient than full records.
Oz records have some advantages, too. They can store Oz variables. You
can unify them, and use pattern matching. IMHO the latter makes many
algorithms much more readable than object-oriented code. If memory is a
concern, you might also read your input file in a lazy way, and build
the part of the tree that you actually need. Moreover, garbage
collection is automatic.
My advice is: don't try to reinvent the world, especially in C++.
Unless it is necessary.
Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users