Jeff Weisberg on Wed, 6 Nov 2002 11:20:06 -0500 |
| algorithm that delete old cached data when the total free memory becomes | low. To get the total (including free swap) free memory I read /proc/meminfo. | I have no knowledge of BSD but IIRC there is no proc filesystem. there might be, there might not be. it probably won't contain the number you're looking for. | What would be the BSD way to get the quantity of free memory? based on experience, but with no actual experimental data to back myself up, I would doubt that using total free memory to determine the cache size is the optimal cache sizing algorithm. | Ideas and of course C code welcome. well, many programs use the cache-sizing algorithm 'read a value from a config file'. untested, and could be made much better: FILE *f; char line[MAXLEN], *v; if( (f=fopen( ".gphoto", "r" ))<0 ){ perror("file is stubborn and refuses to open"); exit(1); } while( fgets(line, sizeof(line), f) ){ if( strstr(line, "cache-size:") ){ v = strchr(line, ':'); while( !isdigit(*v) ){ v++; } cachesize = atoi( v ); } } fclose(f); --jeff _________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce General Discussion -- http://lists.netisland.net/mailman/listinfo/plug
|
|