USLEEP(3) Linux Programmer's Manual USLEEP(3) NAME usleep - suspend execution for microsecond intervals SYNOPSIS /* BSD version */ #include <unistd.h> void usleep(unsigned long usec); /* SUSv2 version */ #define _XOPEN_SOURCE 500 #include <unistd.h> int usleep(useconds_t usec); DESCRIPTION The usleep() function suspends execution of the calling process for (at least) usec microseconds. The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers. |
原帖由 yjcq 于 2009-10-17 09:41 发表
我记得好像是即使分配了内存,如果没有使用的话,是不会占用物理内存的。
分配内存只是分配的虚拟内存,只有对分配的内存进行写数据的时候,才会写时拷贝,真正分配物理内存。
程序二中只是分配的内存没有使用 ...
原帖 ...
刚才在1台2G物理内存的64位机子上测试了一下:每次1G的分配可以进行6万多次
程序二:
#include
#include
main()
{
while(malloc(1024));
perror("error");
}
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |