Ejemplo n.º 1
0
static void
debug_malloc_stats(int signum)
{
#ifndef CURRF2_DEBUG_OFF
	enum debug_level level_save = get_comp_level(MEMORY);
	set_comp_level(MEMORY, VERBOSE);
	show_mem_info();
	set_comp_level(MEMORY, level_save);
#endif
}
Ejemplo n.º 2
0
static void  *constrained_mmap(void *addr, size_t size, int prot , int flags, int fd, off_t offset)
{
	int heap_increase_allowed = !g_constrained_allocation || (get_heap_limit() >= (get_heap_size() + size));

	if ( heap_increase_allowed )
	{
#ifdef SHOW_MEM_INFO
		if ( g_show_mem_info )
		{
			mstate av = get_malloc_state();
			int new_total = av->mmapped_mem + av->sbrked_mem + size;
			if ( av->max_total_mem < new_total )
				show_mem_info(new_total);
		}
#endif
		return mmap(addr, size, prot, flags, fd, offset);
	}

	return (void*) MORECORE_FAILURE;
}
Ejemplo n.º 3
0
/** tags the allocated memory and adjusts the allocation count */
static void constrain_tag_allocation(void *m)
{
	if ( m == NULL )
		return;

	mchunkptr p = mem2chunk(m);

	assert(!(p->size & CONSTRAIN_TAG));
	p->size |= CONSTRAIN_TAG;

	g_constrain_allocated_mem += chunksize(p);

#ifdef SHOW_MEM_INFO
	if ( g_show_mem_info && (g_constrain_allocated_mem > g_max_constrain_allocated_mem) )
	{
		show_mem_info(0);
		g_max_constrain_allocated_mem = g_constrain_allocated_mem;
	}
#endif

}
Ejemplo n.º 4
0
static void *constrained_sbrk(intptr_t increment)
{
	/* increment == 0 is used to find the current break, so we must always let
	 * it through, and it should ofcourse always be possible to decrease the
	 * heap size...
	 */
	int heap_increase_allowed = !g_constrained_allocation || increment <= 0 || (get_heap_limit() >= (get_heap_size() + increment));

	if ( heap_increase_allowed )
	{
#ifdef SHOW_MEM_INFO
		if ( g_show_mem_info )
		{
			mstate av = get_malloc_state();
			int new_total = av->mmapped_mem + av->sbrked_mem + increment;
			if ( av->max_total_mem < new_total )
				show_mem_info(new_total);
		}
#endif
		return sbrk(increment);
	}
	return (void*) MORECORE_FAILURE;
}