From: riley@krakatoa.uucp (Gary Riley [PT4])
Newsgroups: comp.ai.shells
Subject: CLIPS Memory Usage
Date: 13 Apr 92 19:46:38 GMT
Article-I.D.: aio.1992Apr13.194638.20372
Organization: Software Technology Branch - NASA/Johnson Space Center

I've received some requests about the differences in memory usage between
CLIPS 4.3 and 5.1, so I've collected some information and summarized the
results shown below.


  
The tables below show some statistics on the memory usage for loading a large  
rule set (637 rules) into versions 4.3 and 5.1 of CLIPS on the Macintosh. The 
memory requests indicate the total number of memory requests (of whatever size) 
made by CLIPS. The memory used indicates the total amount of memory requested 
(e.g. 10 requests of 30 bytes would yield a memory used of 300). The total 
memory used factors in the system overhead added for each memory request.
Upon startup (before loading), CLIPS 5.1 takes up more memory than CLIPS 4.3 
(in large part because more data structures are initialized). The total memory 
used difference is also attributable to the much larger size of the CLIPS 5.1
executable (more features). The most interesting statistics occur after the 
rules have been loaded. CLIPS 5.1 takes up less memory for two main reasons. 
First, fewer data structures are actually allocated. Second, linked lists of 
data structures are "packed" into a single contiguous piece of memory. Thus, 
instead of making 10 requests of X bytes for a linked list of 10 items, CLIPS
makes a single request of 10 * X bytes and stores the data structures in that 
memory request as if it were an array. This substantially cuts down on the 
number of memory requests and subsequently cuts down on the system overhead of 
allocating memory. The total memory used difference (after load minus before 
load) is dramatic, but partly skewed. Version 4.3 of CLIPS used the block 
memory routines provided by CLIPS (which request large blocks of memory from
the system and then splits it into small chunks for CLIPS memory requests)
to allocate memory since the allocation routines provided by the Think C 
compiler at that time were rather inefficient. The block memory routines in 
CLIPS are relatively fast, but gobble up lots of memory (16 bytes of overhead 
for every request). Since the average memory request in 4.3 was 14 bytes, 
the overhead for keeping track of the allocated memory was actually higher 
than the amount of memory allocated. Version 5.1 of CLIPS did not make use
of block memory since the memory allocation routines provided by the 
version of Think C had dramatically improved since the release of version
4.3 of CLIPS.
  
  
                      CLIPS 4.3         CLIPS 5.1

Memory Requests         227              1,527
Before Load
 
Memory Used               4K                38K
Before Load      
  
Total Memory Used       297K               523K
Before Load
  
Memory Requests     125,880             18,542
After Load
  
Memory Used            1767K               878K
After Load      
  
Total Memory Used      4299K              1505K
After Load
  
Memory Requests     125,635             17,015
Difference
  
Memory Used           1,763K               840K
Difference
  
Total Memory Used     4,002K               982K
Difference
  


Gary Riley
Software Technology Branch
Johnson Space Center
Newsgroups: comp.ai,comp.ai.edu