当前位置:网站首页>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》

边栏推荐
- Wechat can play the trumpet. Pinduoduo was found guilty of infringement. The shipment of byte VR equipment ranks second in the world. Today, more big news is here
- 主设备号和次设备号均为0
- namespace基础介绍
- Lessons and thoughts of the first SQL injection
- [OA] excel document generator: openpyxl module
- Fix the problem that the highlight effect of the main menu disappears when the easycvr Video Square is clicked and played
- Thesis landing strategy | how to get started quickly in academic thesis writing
- Have you got the same "artifact" of cross architecture development praised by various industry leaders?
- 一度辍学的数学差生,获得今年菲尔兹奖
- Highly paid programmers & interview questions. Are you familiar with the redis cluster principle of series 120? How to ensure the high availability of redis (Part 1)?
猜你喜欢

这项15年前的「超前」技术设计,让CPU在AI推理中大放光彩

namespace基础介绍

R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标

mpf2_ Linear programming_ CAPM_ sharpe_ Arbitrage Pricin_ Inversion Gauss Jordan_ Statsmodel_ Pulp_ pLU_ Cholesky_ QR_ Jacobi

深耕开发者生态,加速AI产业创新发展 英特尔携众多合作伙伴共聚

kivy教程之设置窗体大小和背景(教程含源码)

Why does WordPress open so slowly?

Video fusion cloud platform easycvr video Plaza left column list style optimization

DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)

案例大赏:英特尔携众多合作伙伴推动多领域AI产业创新发展
随机推荐
赠票速抢|行业大咖纵论软件的质量与效能 QECon大会来啦
Easycvr cannot be played using webrtc. How to solve it?
[multi threading exercise] write a multi threading example of the producer consumer model.
What is CGI, IIS, and VPS "suggested collection"
Mathematical analysis_ Notes_ Chapter 10: integral with parameters
EasyCVR集群版本添加RTSP设备提示服务器ID错误,该如何解决?
[team learning] [phase 34] Baidu PaddlePaddle AI talent Creation Camp
Kotlin compose text supports two colors
Advertising attribution: how to measure the value of buying volume?
A detailed explanation of head pose estimation [collect good articles]
Data security -- 12 -- Analysis of privacy protection
Common methods of list and map
sscanf,sscanf_s及其相关使用方法「建议收藏」
[OA] excel document generator: openpyxl module
The request request is encapsulated in uni app, which is easy to understand
VM virtual machine operating system not found and NTLDR is missing
Video fusion cloud platform easycvr video Plaza left column list style optimization
ACL2022 | 分解的元学习小样本命名实体识别
Fix the problem that the highlight effect of the main menu disappears when the easycvr Video Square is clicked and played
True global ventures' newly established $146million follow-up fund was closed, of which the general partner subscribed $62million to invest in Web3 winners in the later stage