Too many cells open (ERROR)

I have developed a visualization tool to visualize the NPS (nonpoint source)
pollution model outputs. The model I used is the AGNPS.

The tool creates 17 different output maps and allows to display them on the
screen. I am using D_LIB functions like Dcell, Derase etc to display
and erase the windows. After a while I am getting an error saying that
"Too may raster maps open" and the program dies. Also, in my tool I am using
similar to programs like d.what.rast to open a raster map and close once
done with it.

1. Is there any limitation of how many number of raster maps can be used
in a program?

2. If there is a limitation, is there some way where one could release the
open and closing of raster maps from memory. I think some how it keeps
all the records of raster file open ids and gives this error.

Any help in this matter appreciated.

More problems are encountered when transferring the programs from GRASS3.1
version to GRASS4.0, especially in color structures manipulation.

R. Srinivasan
srin@ecn.purdue.edu