To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1327
1326  |  1328
Subject: 
dont't fear the reaper
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Mon, 31 Jul 2000 19:14:46 GMT
Viewed: 
1210 times
  
I've tried to test the maximum memory allocation possible in legOS. For that, I
wrote the following test program:

#include <conio.h>
#include <unistd.h>
#include <stdlib.h>

int main( int argc, char **argv ) {
int i;
char *cp;

   i = 1;
   while( ( cp = malloc( 1024*i ) ) != NULL ) {
      lcd_int( i++ );
      sleep( 1 );
      free( cp );
   }
   return 0;
}

This program runs up to 16 and stops. But when I stop the program with the
run-key, the next run will stop a lot erlier. In fact, if I stop after the
display of "3", the next run will only count up to 13. After a while, all
memory is eaten up and the program won't start at all.

The culprit for that is the routine mm_reaper in mm.c There are two lines
reading:

while(*ptr>=(size_t) &mm_start) { ...

please change them both to:

while(ptr>=(size_t) &mm_start) { ...

No deference of ptr!!

Then, after the death of a program, all allocated memory will be freed
correctly.

Mike



Message has 1 Reply:
  Re: dont't fear the reaper
 
(...) This change is correct, although it will not work by itself. Using only this all memory will be freed when the RCX is powered off, including program memory. To work correctly another change to tm.c is necessary, so memory allocated by kernel (...) (24 years ago, 1-Aug-00, to lugnet.robotics.rcx.legos)

10 Messages in This Thread:





Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR