Click here to Skip to main content
15,918,889 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: Php learner Pin
Kristian Sixhøj30-Sep-08 23:21
Kristian Sixhøj30-Sep-08 23:21 
AnswerRe: Php learner Pin
Mohammad Dayyan2-Oct-08 12:30
Mohammad Dayyan2-Oct-08 12:30 
GeneralRe: Php learner Pin
Pedram Behroozi7-Oct-08 7:40
Pedram Behroozi7-Oct-08 7:40 
AnswerRe: Php learner Pin
hamid zamani8-Oct-08 8:34
hamid zamani8-Oct-08 8:34 
GeneralRe: Php learner Pin
Pedram Behroozi8-Oct-08 8:37
Pedram Behroozi8-Oct-08 8:37 
GeneralRe: Php learner Pin
hamid zamani8-Oct-08 8:51
hamid zamani8-Oct-08 8:51 
AnswerRe: Php learner Pin
Perspx19-Oct-08 1:40
Perspx19-Oct-08 1:40 
QuestionMemory released for standard data types and not for user defined data types...? Pin
deepak190523-Sep-08 21:01
deepak190523-Sep-08 21:01 
Hi,

I am working on c++ in a linux system ( Fedora core 4 ),
kernel version - 2.6.11-1.1369_FC4
gcc version - 4.0.0 20050519 ( Red Hat 4.0.0-8 )

In my code i am creating a vector to store pointers of type structure "SAMPLE_TABLE_STRUCT" ( size of this

structure is 36 bytes ). I create an instance of structure "SAMPLE_TABLE_STRUCT" using operator "new" and push back

into the vector,this is done inside a for loop for 204800 times. After i come out of for loop i observe the memory

consumed by the process using the command "pmap -d pid". The memory consumption increases by approximately 8 MB.

After this i delete all the contents of vector using "delete" operator. Now if i observe the memory consumed by the

process ( using "pmap -d pid" command ) it shows no reduction in the memory even after deallocating the memory in

the code.

But it shows memory reduction after deleting vector contents if i store the "char *" elements into the vector

instead of "SAMPLE_TABLE_STRUCT *" elements.

Am not able to figure it out why it does not show memory reduction ( after deleting vector contents ) in case of

vector of type "SAMPLE_TABLE_STRUCT *" whereas it shows reduction in memory for vector of "char *" type elements(

after deleting vector contents )...?

Can anyone please help me out here...?

Here is the piece of code where am facing the problem -

[CODE]

#define ALTERNATE

#define MAX_STRING_VEC_SIZE 134
#define MAX_STRUCT_VEC_SIZE 1024*200//134
#define MAX_MEM_SIZE 1024*50


/*vector of char * type*/
void Function()
{
std::vector< char * > v_pData;

#ifdef ALTERNATE
v_pData.resize( MAX_STRING_VEC_SIZE, NULL );
#endif //ALTERNATE

bool bFlag = true;
while( bFlag );

//Allocate Memory
for( int nInd = 0 ; nInd < MAX_STRING_VEC_SIZE; nInd++ )
{
char * pData = new char [MAX_MEM_SIZE];
memset( pData, 0, MAX_MEM_SIZE );

#ifdef ALTERNATE
v_pData[nInd] = pData;
#else //ALTERNATE
v_pData.push_back( pData );
#endif //#endif //ALTERNATE

}

bFlag = true;
while( bFlag );

//Release all the Memory
for( int nInd = 0 ; nInd < MAX_STRING_VEC_SIZE; nInd++ )
{
delete [] v_pData[nInd];
}

v_pData.clear();
}

/*vector of SAMPLE_TABLE_STRUCT * type*/
void Function1()
{
std::vector< SAMPLE_TABLE_STRUCT * > v_pData;

#ifdef ALTERNATE
v_pData.resize( MAX_STRUCT_VEC_SIZE, NULL );
#endif //ALTERNATE

//Allocate Memory
for( int nInd = 0 ; nInd < MAX_STRUCT_VEC_SIZE; nInd++ )
{
SAMPLE_TABLE_STRUCT * pData = new SAMPLE_TABLE_STRUCT;

#ifdef ALTERNATE
v_pData[nInd] = pData;
#else //ALTERNATE
v_pData.push_back( pData );
#endif //#endif //ALTERNATE

}

//Release all the Memory
for( int nInd = 0 ; nInd < MAX_STRUCT_VEC_SIZE; nInd++ )
{
delete v_pData[nInd];
v_pData[nInd] = NULL;
}

v_pData.clear();
}

[/CODE]
QuestionCreating a Unix shell Pin
crain198123-Sep-08 6:34
crain198123-Sep-08 6:34 
AnswerRe: Creating a Unix shell Pin
Shyam Bharath19-Oct-08 1:43
Shyam Bharath19-Oct-08 1:43 
QuestionI can't get variables from forms Pin
blackhattrick16-Sep-08 10:18
blackhattrick16-Sep-08 10:18 
AnswerRe: I can't get variables from forms Pin
Kristian Sixhøj23-Sep-08 1:00
Kristian Sixhøj23-Sep-08 1:00 
AnswerRe: I can't get variables from forms Pin
Mohammad Dayyan24-Sep-08 16:22
Mohammad Dayyan24-Sep-08 16:22 
AnswerRe: I can't get variables from forms Pin
Ranjit Viswakumar29-Jan-09 13:52
Ranjit Viswakumar29-Jan-09 13:52 
QuestionWhat's python's claim to fame? Pin
MikeMarq14-Sep-08 18:42
MikeMarq14-Sep-08 18:42 
AnswerRe: What's python's claim to fame? Pin
Paul Coldrey7-Oct-08 15:14
professionalPaul Coldrey7-Oct-08 15:14 
GeneralRe: What's python's claim to fame? Pin
MikeMarq20-Oct-08 3:07
MikeMarq20-Oct-08 3:07 
GeneralRe: What's python's claim to fame? Pin
Paul Coldrey20-Oct-08 13:06
professionalPaul Coldrey20-Oct-08 13:06 
GeneralRe: What's python's claim to fame? Pin
MikeBeard27-Jan-09 5:36
MikeBeard27-Jan-09 5:36 
AnswerRe: What's python's claim to fame? Pin
MikeBeard27-Jan-09 5:45
MikeBeard27-Jan-09 5:45 
GeneralRe: What's python's claim to fame? Pin
Anonymous3-Apr-09 12:04
Anonymous3-Apr-09 12:04 
GeneralRe: What's python's claim to fame? Pin
Anonymous24-Apr-09 17:17
Anonymous24-Apr-09 17:17 
Questionkernel programing in linux Pin
gulavaniashish11-Sep-08 23:44
gulavaniashish11-Sep-08 23:44 
QuestionDot Net Framework for Linux Platform Pin
Lakul5-Sep-08 23:07
Lakul5-Sep-08 23:07 
AnswerRe: Dot Net Framework for Linux Platform Pin
avdesh1225-Sep-08 10:29
avdesh1225-Sep-08 10:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.