繁调用moveGroup()时,内存会很快用光,请问该如何解决?

Hi

程序中当频繁调用moveGroup()时,内存会很快用光,请问该如何解决?

int

moveGroup( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo,int type )



{

PhPoint_t new_position[20];

PhImage_t *group_image;

PxMethods_t image_methods;

memset( &image_methods, 0, sizeof( PxMethods_t ) );

image_methods.px_alloc = memory_allocate;

image_methods.px_free = memory_free;



/* eliminate ‘unreferenced’ warnings */

widget = widget, apinfo = apinfo, cbinfo = cbinfo;



if( type == 1)

{

//load image for BG

if ((group_image = PxLoadImage(image_group.bg_path, &image_methods))!=NULL)

{

PtSetArg(&args[0], Pt_ARG_BKGD_IMAGE, group_image, NULL);

PtSetResources(ABW_PtBkgd_group, 1, args);

}



//load ok image

if ((group_image = PxLoadImage(image_group.ok_up_path, &image_methods))!=NULL)

{

PtSetArg(&args[0], Pt_ARG_LABEL_IMAGE, group_image, NULL);

PtSetResources(ABW_PtButton_gok, 1, args);

}



if ((group_image = PxLoadImage(image_group.ok_dn_path, &image_methods))!=NULL)

{

PtSetArg(&args[0], Pt_ARG_ARM_IMAGE, group_image, NULL);

PtSetResources(ABW_PtButton_gok, 1, args);

}





//load cacel image

if ((group_image = PxLoadImage(image_group.cancel_up_path, &image_methods))!=NULL)

{

PtSetArg(&args[0], Pt_ARG_LABEL_IMAGE, group_image, NULL);

PtSetResources(ABW_PtButton_gcancel, 1, args);

}



if ((group_image = PxLoadImage(image_group.cancel_dn_path, &image_methods))!=NULL)

{

PtSetArg(&args[0], Pt_ARG_ARM_IMAGE, group_image, NULL);

PtSetResources(ABW_PtButton_gcancel, 1, args);

}



group_image->flags |= Ph_RELEASE_IMAGE_ALL;

PhReleaseImage(group_image);

free(group_image);



new_position[0].x=text_position[0].x;

new_position[0].y=text_position[0].y;

new_position[1].x=text_position[1].x;

new_position[1].y=text_position[1].y;

new_position[2].x=text_position[2].x;

new_position[2].y=text_position[2].y;

new_position[3].x=text_position[3].x;

new_position[3].y=text_position[3].y;

new_position[4].x=text_position[4].x;

new_position[4].y=text_position[4].y;

new_position[5].x=text_position[5].x;

new_position[5].y=text_position[5].y;

new_position[6].x=text_position[6].x;

new_position[6].y=text_position[6].y;

new_position[7].x=text_position[7].x;

new_position[7].y=text_position[7].y;

new_position[8].x=text_position[8].x;

new_position[8].y=text_position[8].y;

new_position[9].x=text_position[9].x;

new_position[9].y=text_position[9].y;

new_position[10].x=text_position[10].x;

new_position[10].y=text_position[10].y;

new_position[11].x=text_position[12].x;

new_position[11].y=text_position[12].y;

new_position[12].x=text_position[13].x;

new_position[12].y=text_position[13].y;

new_position[13].x=text_position[14].x;

new_position[13].y=text_position[14].y;

new_position[14].x=text_position[15].x;

new_position[14].y=text_position[15].y;

new_position[15].x=text_position[16].x;

new_position[15].y=text_position[16].y;

new_position[16].x=text_position[17].x;

new_position[16].y=text_position[17].y;

new_position[17].x=text_position[18].x;

new_position[17].y=text_position[18].y;

new_position[18].x=text_position[19].x;

new_position[18].y=text_position[19].y;



if(strcmp(image_group.cursor_text,“pa1”)==0)

{

tmp_widget = ABW_PtText_pa1;

tmp_len = image_group.nu1_len;

PtGiveFocus(tmp_widget,NULL);

}

else if(strcmp(image_group.cursor_text,“nu1”)==0)

{

tmp_widget = ABW_PtText_nu1;

tmp_len = image_group.nu1_len;

PtGiveFocus(tmp_widget,NULL);

}

else if(strcmp(image_group.cursor_text,“tx1”)==0)

{

tmp_widget = ABW_PtText_tx1;

tmp_len = image_group.tx1_len;

PtGiveFocus(tmp_widget,NULL);

}



}

else

{

new_position[0].x=2000;

new_position[0].y=1000;

new_position[1].x=2000;

new_position[1].y=1000;

new_position[2].x=2000;

new_position[2].y=1000;

new_position[3].x=2000;

new_position[3].y=1000;

new_position[4].x=2000;

new_position[4].y=1000;

new_position[5].x=2000;

new_position[5].y=1000;

new_position[6].x=2000;

new_position[6].y=1000;

new_position[7].x=2000;

new_position[7].y=1000;

new_position[8].x=2000;

new_position[8].y=1000;

new_position[9].x=2000;

new_position[9].y=1000;

new_position[10].x=2000;

new_position[10].y=1000;

new_position[11].x=2000;

new_position[11].y=1000;

new_position[12].x=2000;

new_position[12].y=1000;

new_position[13].x=2000;

new_position[13].y=1000;

new_position[14].x=2000;

new_position[14].y=1000;

new_position[15].x=2000;

new_position[15].y=1000;

new_position[16].x=2000;

new_position[16].y=1000;

new_position[17].x=2000;

new_position[17].y=1000;

new_position[18].x=2000;

new_position[18].y=1000;

}



PtSetArg(&args[0], Pt_ARG_POS, &new_position[0], NULL);

PtSetResources(ABW_PtBkgd_group, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[1], NULL);

PtSetResources(ABW_PtText_pa1, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[2], NULL);

PtSetResources(ABW_PtText_pa2, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[13], NULL);

PtSetResources(ABW_PtText_pa3, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[3], NULL);

PtSetResources(ABW_PtText_nu1, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[4], NULL);

PtSetResources(ABW_PtText_nu2, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[14], NULL);

PtSetResources(ABW_PtText_nu3, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[5], NULL);

PtSetResources(ABW_PtText_tx1, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[6], NULL);

PtSetResources(ABW_PtText_tx2, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[7], NULL);

PtSetResources(ABW_PtText_tx3, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[8], NULL);

PtSetResources(ABW_PtText_tx4, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[9], NULL);

PtSetResources(ABW_PtText_tx5, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[10], NULL);

PtSetResources(ABW_PtText_tx6, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[15], NULL);

PtSetResources(ABW_PtText_tx7, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[16], NULL);

PtSetResources(ABW_PtText_tx8, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[17], NULL);

PtSetResources(ABW_PtText_tx9, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[18], NULL);

PtSetResources(ABW_PtText_tx10, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[11], NULL);

PtSetResources(ABW_PtButton_gok, 1, args);

PtSetArg(&args[0], Pt_ARG_POS, &new_position[12], NULL);

PtSetResources(ABW_PtButton_gcancel, 1, args);



return( Pt_CONTINUE );



}