This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

mistake with Heap

Hi!

I use RTX.
In my program except the others there are three processes
Here they

OS_MUT LOG_MUTEX;
#define INIT_LOG_LOCK os_mut_init(LOG_MUTEX)
#define LOCK_LOG os_mut_wait(LOG_MUTEX,0xFFFF)
#define RELEASE_LOG os_mut_release(LOG_MUTEX)


__task void tcp_task (void) {
   /* Main Thread of the TcpNet. This task should have */
   /* the lowest priority because it is always READY. */

        INIT_LOG_LOCK;

while (1)
{
 LOCK_LOG;
  main_TcpNet();
 RELEASE_LOG;
 os_tsk_pass();
 }
}


__task void GetHeapsState(void)
{
  char *ptr;
 unsigned int max=0;

while(1)
{
  LOCK_LOG;
  tsk_lock();

   max=1;

  do{

         ptr=(char*)malloc(max);
         if(ptr)
         {
          max+=1;
          free(ptr);
         }
   } while(ptr);

   printf("%d\r\n",max);
   tsk_unlock();
        RELEASE_LOG;
        os_dly_wait(10);
}

}

__task void CreatXML(void)
{
   FILE *file_xml = NULL;
 LOCK_LOG;
while(1)
{
 do
 {
  file_xml = fopen ("monitor.xml","w");
  if(file_xml==NULL)
         break;
  fputs("<?xml version=\"1.0\" encoding=\"WINDOWS-1251\"?><form>\r\n",file_xml);
  ....

  fputs("</form>",file_xml);
  fclose(file_xml);
  }
  while(0);
  RELEASE_LOG;
  os_dly_wait(10);
 }

}


In the beginning GetHeapsState outputs size of the maximum mount memory (number 3909 byte is output).
If I will start Explorer and begin to request periodical file monitor.xml after a little later as much as possible selected memory size in the task of GetHeapsState will: 3821 byte.
And this number will not change any more does not vary even if we will terminat the request of file monitor.xml.
Can you explain me Where disappear 88 byte? I have noticed that the given mistake appears faster if in a parallel way to begin sending any file on fttp.