[Mapserver-dev] MAXLAYERS, MAXSTYLES, MAXCLASSES all that necessary ?

Attila Csipa bear at prometheus.org.yu
Fri Mar 28 04:27:09 EST 2003


On Thursday 27 March 2003 18:21, Daniel Morissette wrote:
> > #define MS_MAXLAYERS 1000 /* maximum number of layers in a map file */
> Is this really an intentional change?  This can have a quite significant
> impact on memory usage.

While we are at it, I'd like to ask why isn't this solved ina semi-dynamic way 
? We all know that the issue of insufficient layer/class space keeps popping 
up in the lists, but I'm not sure why it has to be done this way. 

If there has been a discussion about this I'm sorry for bringing it up again.

If I'm correct the problem is here:

int initMap(mapObj *map)
{
  map->numlayers = 0;
  if((map->layers = (layerObj *)malloc(sizeof(layerObj)*MS_MAXLAYERS)) == 
NULL) {
    msSetError(MS_MEMERR, NULL, "initMap()");
    return(-1);
  }
...

So if MAXLAYERS is high, we're mallocing huge amounts of data. My question is, 
why is this better then mallocing a fixed amount (which would be, say, the 
current MS_MAXLAYERS value), and then when/if we fill up this space just do a 
realloc on a new layer init (this could be done by duplicating allocated 
space and not simply increasing so overhead of both processing and memory 
would not be significant). This way there would be only a memory limit on the 
number of layers and classes, while the loss of speed would be insignificant 
(advanced users could still change the initial number of layers, in which 
case there would be practically no slowdown).


Regards,
Attila






More information about the mapserver-dev mailing list