dot-check_memory_usage function

validate memory before allocation