Networking Forums

Networking Forums > Computer Networking > Linux Networking > Mysterious behavior in RedHat Linux

Reply
Thread Tools Display Modes

Mysterious behavior in RedHat Linux

 
 
Ramki
Guest
Posts: n/a

 
      12-02-2004, 10:58 AM
Hi,

I have observed a mysteries behavior in the following program on Red
Hat Linux 8.0.

I am allocating 24MB memory and freeing it.

The processes memory grows up to 24MB and it stays there even if I
free the memory in "ReleaseMemoryL()" function.

But if I remove the line "MemList.push_back(i);", the program works
fine.

Can anybody help me to sort out this problem?

TIA,
Ramki

#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>

#include <list>
#include <iostream>
#include <fstream>

using namespace std;

const int LOOP = 24000;
const int SIZE = 1024;

typedef list<int > Deque;

Deque MemList;

char *CharArray [LOOP];

void AllocMemoryL()
{
for (int i=0;i<LOOP;i++)
{
char *mem = new char[SIZE];
MemList.push_back(i);
CharArray[i] = mem;
}
}

void ReleaseMemoryL()
{
for (int i=0;i<LOOP;i++)
{
delete [] CharArray[i];
}
MemList.clear();
}

int main(int argc, char const * argv[])
{
cout<<"Allocating memory"<<endl;
AllocMemoryL();
cout<<"Allocated memory successfully"<<endl;
char ch;
cin>>ch;

cout<<"Releasing memory"<<endl;
ReleaseMemoryL();
cout<<"Released memory successfully"<<endl;
cin>>ch;

return 0;
}
 
Reply With Quote
 
 
 
 
Simon J. Rowe
Guest
Posts: n/a

 
      12-02-2004, 11:42 AM
This is how Unix has worked since forever, memory allocated (via brk()) is
only released when the process terminates.
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redhat Linux 8 and Redhat Enterprise Linux 4 printer not configure Niraj Linux Networking 0 12-06-2006 04:51 AM
Proper behavior of dhcp on linux Andrew Falanga Linux Networking 3 05-07-2004 07:32 PM
strange behavior of redhat-config-network with 2 nic matthieu imbert Linux Networking 0 04-15-2004 11:01 AM
Red Hot Linux v9.0 [2 DVDs]. Red Hot Linux v9.0 [3 CDs]. Redhat Enterprise Linux ES v3.0 REPACK [4 CDs]. Mandrake Linux 9.2 [3 CDs] -new ! TEL Linux Networking 0 12-01-2003 12:06 PM
Red Hot Linux v9.0 [2 DVDs]. Red Hot Linux v9.0 [3 CDs]. Redhat Enterprise Linux ES v3.0 REPACK [4 CDs]. Mandrake Linux 9.2 [3 CDs] - new ! TEL Linux Networking 0 11-29-2003 11:27 AM



1 2 3 4 5 6 7 8 9 10 11