Snort mailing list archives
Re: Stream4 and other stuff
From: Phil Wood <cpw () lanl gov>
Date: Fri, 29 Jun 2001 12:04:59 -0600
Looking at stream4 from a memory allocation and deallocation standpoint. In SaveAlloc, the first thing that is done is a calloc, then a check for memory usage exceeded, then finally a check for the calloc failure. Would it be better to drop the calloc down to just before the failure check? void *SafeAlloc(unsigned long size) { void *tmp; ***from here. stream4_memory_usage += size; /* if we use up all of our RAM, try to free up some stale sessions */ if(stream4_memory_usage > s4data.memcap) { struct timeval tv; struct timezone tz; safe_alloc_faults++; gettimeofday(&tv, &tz); if(!PruneSessionCache((u_int32_t)tv.tv_sec, 0)) { /* if we can't prune due to time, just nuke 5 random sessions */ PruneSessionCache(0, 5); } } ***to here: tmp = (void *) calloc(size, sizeof(char)); if(tmp == NULL) { FatalError("Unable to allocate memory! (%lu bytes in use)\n", stream4_memory_usage); } return tmp; } -- Phil Wood, cpw () lanl gov _______________________________________________ Snort-users mailing list Snort-users () lists sourceforge net Go to this URL to change user options or unsubscribe: http://lists.sourceforge.net/lists/listinfo/snort-users Snort-users list archive: http://www.geocrawler.com/redir-sf.php3?list=snort-users
Current thread:
- Stream4 and other stuff Martin Roesch (Jun 28)
- <Possible follow-ups>
- Re: Stream4 and other stuff Matthew Collins (Jun 29)
- RE: Stream4 and other stuff Mayers, Philip J (Jun 29)
- Re: Stream4 and other stuff Martin Roesch (Jun 29)
- RE: Stream4 and other stuff Mayers, Philip J (Jun 29)
- RE: Stream4 and other stuff Thomas Nilsen (Jun 29)
- RE: Stream4 and other stuff Mayers, Philip J (Jun 29)
- Re: Stream4 and other stuff Martin Roesch (Jun 29)
- Re: Stream4 and other stuff Phil Wood (Jun 29)
- Re: Stream4 and other stuff Martin Roesch (Jun 29)
- Re: Stream4 and other stuff Phil Wood (Jun 29)
- Re: Stream4 and other stuff Martin Roesch (Jun 29)
- Re: Stream4 and other stuff Martin Roesch (Jun 29)