精华内容
下载资源
问答
  • 该系统把程序可用的内存地址映射到硬件内存中的实际地址上,这些任务完全有Windows后台管理,其实际结果是32位处理器上的每个进程都可以使用4GB的内存------无论计算机上有多少硬盘空间(在64位处理器上这个数值会更...
    Windows使用一个系统:虚拟寻址系统。该系统把程序可用的内存地址映射到硬件内存中的实际地址上,这些任务完全有Windows后台管理,其实际结果是32位处理器上的每个进程都可以使用4GB的内存------无论计算机上有多少硬盘空间(在64位处理器上这个数值会更大)。这个4GB内存实际上包含了程序的所有部分------包括可执行代码,代码加载的所有dll,以及程序运行时使用的所有变量的内容。这个4GB内存称为虚拟地址空间,或虚拟内存。
    展开全文
  • 这个问题的产生是因为windows32位系统,一个进程所能使用的最在虚拟内存为2G,而一个线程的默认StackSize为1024K(1M),这样当线程数量逼近2000时,2000*1024K=2G(大约),内存资源就相当于耗尽。 文档如下: ...

    这个问题的产生是因为windows32位系统,一个进程所能使用的最在虚拟内存为2G,而一个线程的默认StackSize为1024K(1M),这样当线程数量逼近2000时,2000*1024K=2G(大约),内存资源就相当于耗尽。

    文档如下:


    Does Windows have a limit of 2000 threads per process?
         Often I see people asking why they can't create more than around 2000 threads in a process. The reason is not that there is any particular limit inherent in Windows. Rather, the programmer failed to take into account the amount of address space each thread uses.

         A thread consists of some memory in kernel mode (kernel stacks and object management), some memory in user mode (the thread environment block, thread-local storage, that sort of thing), plus its stack. (Or stacks if you're on an Itanium system.)

         Usually, the limiting factor is the stack size.

     

    #include <stdio.h>
    #include <windows.h>
    DWORD CALLBACK ThreadProc(void*)
    {
         Sleep(INFINITE);
         return 0;
    }
    int __cdecl main(int argc, const char* argv[])
    {
         int i;
         for (i = 0; i < 100000; i++)
         {
              DWORD id;
              HANDLE h = CreateThread(NULL, 0, ThreadProc, NULL, 0, &id);
              if (!h)
                   break;
              CloseHandle(h);
         }
         printf("Created %d threads\n", i); return 0;
    }


         This program will typically print a value around 2000 for the number of threads.

         Why does it give up at around 2000?

         Because the default stack size assigned by the linker is 1MB, and 2000 stacks times 1MB per stack equals around 2GB, which is how much address space is available to user-mode programs.

         You can try to squeeze more threads into your process by reducing your stack size, which can be done either by tweaking linker options or manually overriding the stack size passed to the CreateThread functions as described in MSDN.

          HANDLE h = CreateThread(NULL, 4096, ThreadProc, NULL, STACK_SIZE_PARAM_IS_A_RESERVATION, &id);

         With this change, I was able to squeak in around 13000 threads. While that's certainly better than 2000, it's short of the naive expectation of 500,000 threads. (A thread is using 4KB of stack in 2GB address space.) But you're forgetting the other overhead. Address space allocation granularity is 64KB, so each thread's stack occupies 64KB of address space even if only 4KB of it is used. Plus of course you don't have free reign over all 2GB of the address space; there are system DLLs and other things occupying it.

         But the real question that is raised whenever somebody asks, "What's the maximum number of threads that a process can create?" is "Why are you creating so many threads that this even becomes an issue?"

         The "one thread per client" model is well-known not to scale beyond a dozen clients or so. If you're going to be handling more than that many clients simultaneously, you should move to a model where instead of dedicating a thread to a client, you instead allocate an object. (Someday I'll muse on the duality between threads and objects.) Windows provides I/O completion ports and a thread pool to help you convert from a thread-based model to a work-item-based model.

         Note that fibers do not help much here, because a fiber has a stack, and it is the address space required by the stack that is the limiting factor nearly all of the time.

        

         第二种方式:增加连接参数

         /Stack:reverse[,commit]

         注意区别committed   size和reserved   size。  
         默认情况下(除非dwCreationFlags设为STACK_SIZE_PARAM_IS_A_RESERVATION),dwStackSize这个参数用来调整一开始commit给栈的空间,即initially   committed   size。  
       
         那么调整了committed   size后,reserved   size应该怎么有什么相应的调整呢?  
         如果dwStackSize小于默认reserve大小,则reserve   size使用默认reserve大小;  
         如果dwStackSize大于默认reserve   size,则reserve   size将会向上取整变成1MB的整数倍

         如果要求默认的StackSize为64K,则将设置/Stack:65536

        

         第三种方式:用工具editbin.exe(VC工具里)

         editbin /StackSize:reverse[,commit]


     

     

    转载于:https://www.cnblogs.com/liusw/archive/2010/08/11/1797461.html

    展开全文
  • 该系统把程序可用的内存地址映射到硬件内存中的实际地址上,这些任务完全有Windows后台管理,其实际结果是32位处理器上的每个进程都可以使用4GB的内存------无论计算机上有多少硬盘空间(在64位处理器上这个数值会更...
    Windows使用一个系统:虚拟寻址系统。该系统把程序可用的内存地址映射到硬件内存中的实际地址上,这些任务完全有Windows后台管理,其实际结果是32位处理器上的每个进程都可以使用4GB的内存------无论计算机上有多少硬盘空间(在64位处理器上这个数值会更大)。这个4GB内存实际上包含了程序的所有部分------包括可执行代码,代码加载的所有dll,以及程序运行时使用的所有变量的内容。这个4GB内存称为虚拟地址空间,或虚拟内存。



    本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2011/07/21/2113088.html,如需转载请自行联系原作者
    展开全文
  • 这个问题的产生是因为windows32位系统,一个进程所能使用的最在虚拟内存为2G,而一个线程的默认StackSize为1024K(1M),这样当线程数量逼近2000时,2000*1024K=2G(大约),内存资源就相当于耗尽。 第一种方式:...

     

         这个问题的产生是因为windows32位系统,一个进程所能使用的最在虚拟内存为2G,而一个线程的默认StackSize为1024K(1M),这样当线程数量逼近2000时,2000*1024K=2G(大约),内存资源就相当于耗尽。
         

         第一种方式:要求有windows2003SDK
         Does Windows have a limit of 2000 threads per process?
         Often I see people asking why they can't create more than around 2000 threads in a process. The reason is not that there is any particular limit inherent in Windows. Rather, the programmer failed to take into account the amount of address space each thread uses.

         A thread consists of some memory in kernel mode (kernel stacks and object management), some memory in user mode (the thread environment block, thread-local storage, that sort of thing), plus its stack. (Or stacks if you're on an Itanium system.)

         Usually, the limiting factor is the stack size.

     

    #include <stdio.h>
    #include <windows.h>
    DWORD CALLBACK ThreadProc(void*)
    {
         Sleep(INFINITE);
         return 0;
    }
    int __cdecl main(int argc, const char* argv[])
    {
         int i;
         for (i = 0; i < 100000; i++) 
         {
              DWORD id;
              HANDLE h = CreateThread(NULL, 0, ThreadProc, NULL, 0, &id);
              if (!h)
                   break;
              CloseHandle(h);
         }
         printf("Created %d threads\n", i); return 0;
    }

         This program will typically print a value around 2000 for the number of threads.

         Why does it give up at around 2000?

         Because the default stack size assigned by the linker is 1MB, and 2000 stacks times 1MB per stack equals around 2GB, which is how much address space is available to user-mode programs.

         You can try to squeeze more threads into your process by reducing your stack size, which can be done either by tweaking linker options or manually overriding the stack size passed to the CreateThread functions as described in MSDN.

          HANDLE h = CreateThread(NULL, 4096, ThreadProc, NULL, STACK_SIZE_PARAM_IS_A_RESERVATION, &id);

         With this change, I was able to squeak in around 13000 threads. While that's certainly better than 2000, it's short of the naive expectation of 500,000 threads. (A thread is using 4KB of stack in 2GB address space.) But you're forgetting the other overhead. Address space allocation granularity is 64KB, so each thread's stack occupies 64KB of address space even if only 4KB of it is used. Plus of course you don't have free reign over all 2GB of the address space; there are system DLLs and other things occupying it.

         But the real question that is raised whenever somebody asks, "What's the maximum number of threads that a process can create?" is "Why are you creating so many threads that this even becomes an issue?"

         The "one thread per client" model is well-known not to scale beyond a dozen clients or so. If you're going to be handling more than that many clients simultaneously, you should move to a model where instead of dedicating a thread to a client, you instead allocate an object. (Someday I'll muse on the duality between threads and objects.) Windows provides I/O completion ports and a thread pool to help you convert from a thread-based model to a work-item-based model.

         Note that fibers do not help much here, because a fiber has a stack, and it is the address space required by the stack that is the limiting factor nearly all of the time.

         

         第二种方式:增加连接参数

         /Stack:reverse[,commit]

         注意区别committed   size和reserved   size。   
         默认情况下(除非dwCreationFlags设为STACK_SIZE_PARAM_IS_A_RESERVATION),dwStackSize这个参数用来调整一开始commit给栈的空间,即initially   committed   size。   
        
         那么调整了committed   size后,reserved   size应该怎么有什么相应的调整呢?   
         如果dwStackSize小于默认reserve大小,则reserve   size使用默认reserve大小;   
         如果dwStackSize大于默认reserve   size,则reserve   size将会向上取整变成1MB的整数倍

         如果要求默认的StackSize为64K,则将设置/Stack:65536

         

         第三种方式:用工具editbin.exe(VC工具里)

         editbin /StackSize:reverse[,commit]

    转载于:https://www.cnblogs.com/ForEverKissing/archive/2007/11/23/969777.html

    展开全文
  • 32 位Windows上单个进程所能访问的最大内存量是4G,由于操作系统需要给系统核心分配2G的空间,所以一般用户程序的进程使用最大内存为2G。不一定一样,32位的操作系统的进程可访问的最大内存量是4G,这4G包含了...
  • 该系统把程序可用的内存地址映射到硬件内存中的实际地址上,这些任务完全有Windows后台管理,其实际结 果是32位处理器上的每个进程都可以使用4GB的内存------无论计算机上有多少硬盘空间(在64位处理器上这个数值会...
  • 该系统把程序可用的内存地址映射到硬件内存中的实际地址上,这些任务完全有Windows后台管理,其实际结 果是32位处理器上的每个进程都可以使用4GB的内存------无论计算机上有多少硬盘空间(在64位处理器上这个数值会...
  • 这个问题的产生是因为windows32位系统,一个进程所能使用最大虚拟内存为2G,而一个线程的默认线程栈StackSize为1024K(1M),这样当线程数量逼近2000时,2000*1024K=2G(大约),内存资源就相当于耗尽。...
  • 单进程可以创建的最大线程数

    千次阅读 2012-11-20 14:25:11
    这个问题的产生是因为windows32位系统,一个进程所能使用最大虚拟内存为2G,而一个线程的默认线程栈StackSize为1024K(1M),这样当线程数量逼近2000时,2000*1024K=2G(大约),内存资源就相当于耗尽。   ...
  • windowsnt 技术内幕

    2014-04-09 20:47:17
    Windows NT回收站简介 Windows NT帐号简介 理解域模型支持和帐号数量 安全认证号简介 使用管理向导(Administrative Wizards)创建帐号 使用Server Manager(服务器管理器)程序创建计算机帐号 Userver Manager for ...
  • nginx v1.5.9 for windows

    2014-03-27 23:07:53
    因此 在启用多进程时 不能使用共享内存来做SSL的session缓存 也就是说 要实现SSL 只能使用单进程 从而限制了并发连接数 (造成这种结果的原因 可能是作者对Nginx在Windows平台下的应用不太重视 在共享内存使用了...
  • 2,切换到桌面,使用传统内存整理软件进行整理(比如Windows优化大师附带的) 。 3,整理完毕后,恢复游戏,然后再玩玩试试看,游戏会非常的不流畅! “内存救星”来了,而且是免费的! 无论你的电脑配置有多么糟糕...
  • 因此 在启用多进程时 不能使用共享内存来做SSL的session缓存 也就是说 要实现SSL 只能使用单进程 从而限制了并发连接数 (造成这种结果的原因 可能是作者对Nginx在Windows平台下的应用不太重视 在共享内存使用了...
  • 当父进程发现请求数 >= 子进程数时,父进程创建新的子进程,并把子进程数加1(当然子进程数有个预先上限);当父进程发现子进程数大于请求数加1时,父进程杀死多余的子进程。 总的来说,思想是让子进程accept并处理...
  • 让.Net 应用程序突破2G的内存访问限制 Author: Eaglet 32位Windows操作系统下单个进程的用户模式内存访问的限制是2G,如果在boot.ini中设置了/3G开关,则最大为3G,超过3G将无法访问。由于Hubble.net项目是一个...
  • 让.Net 应用程序突破2G的内存访问限制 Author: Eaglet 32位Windows操作系统下单个进程的用户模式内存访问的限制是2G,如果在boot.ini中设置了/3G开关,则最大为3G,超过3G将无法访问。由于Hubble.net项目是一个...
  • WindowsWindows应用程序最大的优点就是用户界面的一致性。 对用户的另一个好处是使用了基于图形的图标来代表应用程序和数据。Windows操作系统提供的“所见即所得”也是一个非常友好的特点。 Windows操作系统还...
  • 加速人生最新文件

    2013-12-08 23:03:45
    这款加速人生文件正是基于让电脑最小化减少软体占用,以保证电脑使用者在运行主要的程序时,能够有稳定的网络环境,更大的CPU、内存空间,以最大化发挥电脑的性能。免安装直接运行即可,所以方便收藏携带,以免被...
  • VMMap 是进程虚拟和物理内存分析实用工具。 VolumeId 设置 FAT 或 NTFS 驱动器的卷 ID。 Whois 查看 Internet 地址的所有者。 WinObj 基本对象管理器命名空间查看器。 ZoomIt 在屏幕上进行缩放和绘图的演示...
  •  5.1.4 Windows驱动程序和进程的关系  5.1.5 分页与非分页内存  5.1.6 分配内核内存  5.2 在驱动中使用链表  5.2.1 链表结构  5.2.2 链表初始化  5.2.3 从首部插入链表  5.2.4 从尾部插入链表  ...
  • Microsoft Windows 系统错误代码简单分析:  0000 操作已成功完成。  0001 错误的函数。  0002 系统找不到指定的文件。  0003 系统找不到指定的路径。  0004 系统无法打开文件。  0005 拒绝访问。...

空空如也

空空如也

1 2 3 4 5 ... 15
收藏数 292
精华内容 116
关键字:

windows单进程最大使用内存