Beispiel #1
0
int cmd_free(int argc, char** argv)
{
    extern void list_mem(void);

    list_mem();
    return 0;
}
Beispiel #2
0
err_t TcpServer::onAccept(tcp_pcb *clientTcp, err_t err)
{
	// Anti DDoS :-)
	if (system_get_free_heap_size() < 6500)
	{
		debugf("\r\n\r\nCONNECTION DROPPED\r\n\t(%d)\r\n\r\n", system_get_free_heap_size());
		return ERR_MEM;
	}

	#ifdef NETWORK_DEBUG
	debugf("onAccept state: %d K=%d", err, totalConnections);
	list_mem();
	#endif

	if (err != ERR_OK)
	{
		//closeTcpConnection(clientTcp, NULL);
		return err;
	}

	TcpConnection* client = createClient(clientTcp);
	if (client == NULL) return ERR_MEM;
	client->setTimeOut(timeOut);
	onClient((TcpClient*)client);

	return ERR_OK;
}
Beispiel #3
0
void showmem(void)
{
	struct mallinfo mi;
	extern int db_store,used_queries;

	mi=mallinfo();

	xlog("-------- Memory usage info: --------");
	xlog("Used characters: %5d/%5d (%4.1f%%)",used_chars,MAXCHARS,100.0/MAXCHARS*used_chars);
	xlog("Used items     : %5d/%5d (%4.1f%%)",used_items,MAXITEM,100.0/MAXITEM*used_items);
	xlog("Used effects   : %5d/%5d (%4.1f%%)",used_effects,MAXEFFECT,100.0/MAXEFFECT*used_effects);
	xlog("Used containers: %5d/%5d (%4.1f%%)",used_containers,MAXCONTAINER,100.0/MAXCONTAINER*used_containers);
	xlog("Used timers    : %5d",used_timers);
	xlog("Used notifies  : %5d",used_msgs);
	xlog("Used queries   : %5d",used_queries);
	xlog("Stored Results : %5d",db_store);
	xlog("server used    : %.3fM",mem_usage/1024.0/1024.0);
	xlog("malloc/mmap    : %.3fM in %d blocks",mi.hblkhd/1024.0/1024.0,mi.hblks);
	xlog("malloc/sbrk    : %.3fM",mi.arena/1024.0/1024.0);
	xlog("malloc/total   : %.3fM",(mi.arena+mi.hblkhd)/1024.0/1024.0);
	xlog("malloc/unused  : %.3fM in %d blocks",(mi.fordblks)/1024.0/1024.0,mi.ordblks);
	xlog("brk has grown  : %.3fM",((int)(sbrk(0))-(int)(end_of_data_ptr))/(1024.0*1024.0));
	xlog("------------------------------------");
	list_mem();
}
/*
rt_uint8_t exist_dev(dev_t *dev)
{
    rt_int8_t fd;
    rt_uint8_t i;
    struct stat buf;
    dev_t *tmpbuff = RT_NULL;
    if((fd = open(DEV, DFS_O_CREAT|DFS_O_RDWR,0))<0)
    {
        rt_kprintf("%s:%d Open %s failed\n",__func__,__LINE__,DEV);
        list_mem();
        return FAILE;
    }
//rt_kprintf("%s:%d Open %s fd = %d\n",__func__,__LINE__,DEV,fd);
    stat(DEV, &buf);
//rt_kprintf("%s:%d buf.st_size = %d\n",__func__,__LINE__,buf.st_size);
    if(buf.st_size>0)
    {
        tmpbuff = (dev_t*)rt_malloc(buf.st_size);
        rt_memset(tmpbuff,0,buf.st_size);
        if(0==tmpbuff)
        {
            rt_kprintf("%s:%d Memory allocation failure\n",__func__,__LINE__);
            goto failed;
        }
        if(read(fd,tmpbuff,buf.st_size)<buf.st_size)
        {
            rt_kprintf("%s:%d Read %s error\n",__func__,__LINE__,DEV);
            goto failed;
        }
        for(i=0;i<(buf.st_size/sizeof(dev_t));i++)
        {
            if(rt_memcmp((tmpbuff+i)->mac,dev->mac,MAC_LEN)==0)
            {
//                rt_kprintf("%s:%d device amc: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x shortadd = %04x\n",__func__,__LINE__,
//                           dev->mac[0],dev->mac[1],dev->mac[2],dev->mac[3],dev->mac[4],dev->mac[5],dev->mac[6],dev->mac[7],dev->shortadd);
                dev->stat = (tmpbuff+i)->stat;
                dev->shortadd = (tmpbuff+i)->shortadd;
//                rt_kprintf("%s:%d device amc: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x shortadd = %04x\n",__func__,__LINE__,
//                           dev->mac[0],dev->mac[1],dev->mac[2],dev->mac[3],dev->mac[4],dev->mac[5],dev->mac[6],dev->mac[7],dev->shortadd);
                goto success;
				
            }
        }
        rt_kprintf("%s:%d device not find\n",__func__,__LINE__);
    }
   goto failed;
   
success:
	if(tmpbuff)
		rt_free(tmpbuff);
	close(fd);
	return SUCCESS;
	
failed:
	if(tmpbuff)
		rt_free(tmpbuff);
	close(fd);
	return FAILE;

}
*/
rt_uint8_t exist_dev(dev_t *dev,int n)
{
    rt_int8_t fd;
    rt_uint8_t i,j;
    struct stat buf;
    dev_t *tmpbuff = RT_NULL;
    if((fd = open(DEV, DFS_O_CREAT|DFS_O_RDWR,0))<0)
    {
        rt_kprintf("%s:%d Open %s failed\n",__func__,__LINE__,DEV);
        list_mem();
        return FAILE;
    }
//rt_kprintf("%s:%d Open %s fd = %d\n",__func__,__LINE__,DEV,fd);
    stat(DEV, &buf);
//rt_kprintf("%s:%d buf.st_size = %d\n",__func__,__LINE__,buf.st_size);
    if(buf.st_size>0)
    {
        tmpbuff = (dev_t*)rt_malloc(buf.st_size);
        rt_memset(tmpbuff,0,buf.st_size);
        if(0==tmpbuff)
        {
            rt_kprintf("%s:%d Memory allocation failure\n",__func__,__LINE__);
            goto failed;
        }
        if(read(fd,tmpbuff,buf.st_size)<buf.st_size)
        {
            rt_kprintf("%s:%d Read %s error\n",__func__,__LINE__,DEV);
            goto failed;
        }
		for(j=0;j<n;j++)
		{
			for(i=0;i<(buf.st_size/sizeof(dev_t));i++)
	        {
	            if(rt_memcmp((tmpbuff+i)->mac,(dev+j)->mac,MAC_LEN)==0)
	            {
	                (dev+j)->stat = (tmpbuff+i)->stat;
	                (dev+j)->shortadd = (tmpbuff+i)->shortadd;
	            }
	        }
		}
        
    }
   goto failed;
   
success:
	if(tmpbuff)
		rt_free(tmpbuff);
	close(fd);
	return SUCCESS;
	
failed:
	if(tmpbuff)
		rt_free(tmpbuff);
	close(fd);
	return FAILE;

}
Beispiel #5
0
int cmd_free(int argc, char** argv)
{
    extern void list_mem(void);

#ifdef RT_USING_MEMHEAP_AS_HEAP
    list_memheap();
#else
    list_mem();
#endif
    return 0;
}
Beispiel #6
0
void list_memdebug(int nStart, int nEnd)
{
#ifdef RT_USING_FINSH
	extern void list_mem(void);
#endif
	t_mem_debug *p;
	uint_t nSize = 0;

	os_thd_Lock();
	if (nEnd == 0)
		nEnd = mem_nCnt;
	for (p = &mem_debug[nStart]; p < &mem_debug[nEnd]; p++) {
		rt_kprintf("%2d %8X %4d %s %d\n", p - &mem_debug[0], (uint_t)p->p, p->size, p->fnmalloc, p->linemalloc);
		if (p->size < 12)//MIN_SIZE = 12, defined in mem.c
			nSize += (12 + 0x0c);
		else
			nSize += (p->size + 0x0c);
	}
	rt_kprintf("total size %d\n", nSize);
#ifdef RT_USING_FINSH
	list_mem();
#endif
	os_thd_Unlock();
}