当前位置:网站首页>Windows are not cheap things
Windows are not cheap things
2022-07-07 04:41:00 【Topomeyer - long development road】
Even though Windows The operating system is window centric , But the window itself is not cheap . what's more ,1985 In, there will be strict memory restrictions , Forcing system designers to make different design decisions .
Let's take the list box control as an example .
In modern design , You can design the list box control as a series of sub window lists , Each sub window represents an entry in the list . that , have 20000 The list box of items will have 20000 Sub window . However , This design concept , stay 1985 Years are completely ridiculous .
Think about it , At that time Windows Around 16 Built by bit processor . Window handle is 16 A value , The interior is just close 64K Pointer to heap memory . A window object is 88 Bytes ( I really counted ), This means that you can create at most about before running out of memory 700 About windows .
what's more , Menus are created in the same 64K In the memory heap , So the actual limit is much lower . Even if the window manager uses more than 64K A pile of (Windows 95 That's what it does ),20000 Windows are also more than 1.5MB Of memory . because 8086 The maximum address space of is 1MB, Even if you use every byte of memory for window objects , You still don't have enough memory .
Besides , Making each list box item a window means that each list box will be a variable height list box , This brings the complexity of managing containers with variable height items .
This violates the API Two general principles of design :(1) Simple things should be simple ,(2)“ Paid games ”, If you do simple things , You should not pay the cost of complex things .
Filling the list box with the actual window will also make “ Virtual list box ” The design of becomes more difficult . Use existing design , You can say “ There are onemillion projects ”, Without actually creating them . ( This is why the window space is divided into “ Customer ” and “ Non customers ” Areas rather than non customer areas are made up of small windows .)
In order to keep up with 16 position Windows Program compatibility ( Thanks a lot WOW layer , These programs can still be used in Windows XP function ), Window handles in the system cannot exceed 65536 individual , Because exceeding this number will affect 16 Normal operation of bit program .( Once created 65537 A window , There will be two with the same 16 Bit handle value window , This is due to the pigeon nest principle .)( Yes , Even today ,16/32 Bit interoperability is still important .)
If the upper limit of windows that the system can create is 65536 A window handle , It contains 100000 The list of files will encounter serious problems . As new functions are added to the window manager , The size of the window object increases over time . Today it is even better than in the past 88 Bytes are even larger . It's best not to create unnecessary windows . If your application design requires you to create thousands of windows , Then you should consider migrating to the windowless model (windowless model), for example Internet Explorer、Word、 List box 、 Tree view 、 List view , Even our scrollbar sample program .
Through windowless model , You get rid of the overhead of a complete window handle , And all the baggage that comes with it . Because the window handle is visible to all processes , Therefore, centralized management of window lists will incur a lot of overhead . If your application has no windows , Then the only program that can access your content is your own program . You don't have to worry about marshalling 、 Cross process synchronization 、Unicode/ANSI transformation 、 External subclassing 、 hook …… If you want , You can also use 1GB Memory to track your windowless data , Because windowless controls do not affect any other processes .
The fact that other processes can access window handles , There is a practical limit on how many window handles can be created without affecting the entire system .
I Believe WinFX Used “ Everything on the screen is an element ” Model of . As far as I know , They built a windowless framework , So you don't have to do it yourself . ( however , I'm not sure about that , I am not WinFX people .)
summary
We need to be alert to the sharp increase in the number of windows , On the one hand, it will increase the difficulty of management , On the other hand , Process GDI There are too many objects , It will also significantly reduce runtime performance .
Interaction design , Make it simple , It's simpler , Flowery is not what we pursue , Good procedure , It should be used up and go .
Last
Raymond Chen Of 《The Old New Thing》 It's one of my favorite blogs , There's a lot about Windows Little knowledge , For the vast Windows For platform developers , It's really helpful .
This article is from :《Windows are not cheap objects》
边栏推荐
- Intel and Xinbu technology jointly build a machine vision development kit to jointly promote the transformation of industrial intelligence
- Kotlin compose text supports two colors
- Zero knowledge private application platform aleo (1) what is aleo
- R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标
- The root file system of buildreoot prompts "depmod:applt not found"
- Web3 社区中使用的术语
- 微信能开小号了,拼多多“砍一刀”被判侵权,字节VR设备出货量全球第二,今日更多大新闻在此
- Is there any way to bookmark the code in the visual studio project- Is there a way to bookmark code in a Visual Studio project?
- 【数模】Matlab allcycles()函数的源代码(2021a之前版本没有)
- Win11图片打不开怎么办?Win11无法打开图片的修复方法
猜你喜欢
视频融合云平台EasyCVR视频广场左侧栏列表样式优化
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Lessons and thoughts of the first SQL injection
[multi threading exercise] write a multi threading example of the producer consumer model.
Introduction to the PureMVC series
Digital chemical plant management system based on Virtual Simulation Technology
How to solve the problem of adding RTSP device to easycvr cluster version and prompting server ID error?
案例大赏:英特尔携众多合作伙伴推动多领域AI产业创新发展
A detailed explanation of head pose estimation [collect good articles]
树与图的深度优先遍历模版原理
随机推荐
Win11 control panel shortcut key win11 multiple methods to open the control panel
sscanf,sscanf_s及其相关使用方法「建议收藏」
Golang compresses and decompresses zip files
JS form get form & get form elements
Two divs are on the same line, and the two divs do not wrap "recommended collection"
sscanf,sscanf_ S and its related usage "suggested collection"
namespace基础介绍
On the 110th anniversary of Turing's birth, has the prediction of intelligent machine come true?
ESG Global Leaders Summit | Intel Wang Rui: coping with global climate challenges with the power of science and technology
mpf2_线性规划_CAPM_sharpe_Arbitrage Pricin_Inversion Gauss Jordan_Statsmodel_Pulp_pLU_Cholesky_QR_Jacobi
Implementation of JSTL custom function library
Kivy tutorial of setting the size and background of the form (tutorial includes source code)
[multi threading exercise] write a multi threading example of the producer consumer model.
How to conduct website testing of software testing? Test strategy let's go!
Network Security Learning - Information Collection
抖音或将推出独立种草社区平台:会不会成为第二个小红书
Depth first traversal template principle of tree and graph
Detect when a tab bar item is pressed
VM virtual machine operating system not found and NTLDR is missing
Fix the problem that the highlight effect of the main menu disappears when the easycvr Video Square is clicked and played