Speichermanagement mit C

Andre Landwehr andre.landwehr at gmx.net
Sun Apr 28 17:49:02 CEST 2002


Hi,
folgendes Testprogramm führe ich aus:
----
#include <malloc.h>
#include <stdio.h>
int main (void) {
  int c;
  char *string;
  printf ("noch nichts passiert\n");
  c=getchar();
  string = (char*) malloc (5000);
  printf ("habe allokiert\n");
  c=getchar();
  free(string);
  printf ("habe freigegeben\n");
  c=getchar();
  return 0;
}
----
Ich schaue mir in einer anderen Konsole mit top an, was mit dem
Speicher passiert. Anfänglich steht in der Spalte "Size" die Zahl
312. Dann allokiere ich Speicher, jetzt steht da 340. Soweit, so
gut. Dann gebe ich den Speicher wieder frei, und es steht immer
noch 340 da. Warum?

Andre

--
 /"\
 \ /
  X  ASCII Ribbon campaign against HTML E-Mail
 / \

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lug-owl.de/pipermail/linux/attachments/20020428/da1888f3/attachment.sig>


More information about the Linux mailing list