当前位置:网站首页>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》
边栏推荐
- Jetson nano配置pytorch深度学习环境//待完善
- [multi threading exercise] write a multi threading example of the producer consumer model.
- Win11远程桌面连接怎么打开?Win11远程桌面连接的五种方法
- R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标
- 测试/开发程序员怎么升职?从无到有,从薄变厚.......
- Win11 control panel shortcut key win11 multiple methods to open the control panel
- What if the win11 screenshot key cannot be used? Solution to the failure of win11 screenshot key
- Complimentary tickets quick grab | industry bigwigs talk about the quality and efficiency of software qecon conference is coming
- 这项15年前的「超前」技术设计,让CPU在AI推理中大放光彩
- Implementation of JSTL custom function library
猜你喜欢
[OA] excel document generator: openpyxl module
1.19.11. SQL client, start SQL client, execute SQL query, environment configuration file, restart policy, user-defined functions, constructor parameters
Why does WordPress open so slowly?
EasyCVR集群版本添加RTSP设备提示服务器ID错误,该如何解决?
NTU notes 6422quiz review (1-3 sections)
The request request is encapsulated in uni app, which is easy to understand
namespace基础介绍
Have you got the same "artifact" of cross architecture development praised by various industry leaders?
acwing 843. n-皇后问题
Ssm+jsp realizes enterprise management system (OA management system source code + database + document +ppt)
随机推荐
未婚夫捐5亿美元给女PI,让她不用申请项目,招150位科学家,安心做科研!
Dab-detr: dynamic anchor boxes are better queries for Detr translation
acwing 843. N-queen problem
A picture to understand! Why did the school teach you coding but still not
[multi threading exercise] write a multi threading example of the producer consumer model.
acwing 843. n-皇后问题
sscanf,sscanf_ S and its related usage "suggested collection"
Break the memory wall with CPU scheme? Learn from PayPal to expand the capacity of aoteng, and the volume of missed fraud transactions can be reduced to 1/30
Introduction to the PureMVC series
In cooperation with the research team of the clinical trial center of the University of Hong Kong and Hong Kong Gangyi hospital, Kexing launched the clinical trial of Omicron specific inactivated vacc
广告归因:买量如何做价值衡量?
Have you got the same "artifact" of cross architecture development praised by various industry leaders?
How to conduct website testing of software testing? Test strategy let's go!
A detailed explanation of head pose estimation [collect good articles]
mpf2_线性规划_CAPM_sharpe_Arbitrage Pricin_Inversion Gauss Jordan_Statsmodel_Pulp_pLU_Cholesky_QR_Jacobi
食堂用户菜品关系系统(C语言课设)
Five years of automated testing, and finally into the ByteDance, the annual salary of 30W is not out of reach
What is CGI, IIS, and VPS "suggested collection"
Poor math students who once dropped out of school won the fields award this year
Up to 5million per person per year! Choose people instead of projects, focus on basic scientific research, and scientists dominate the "new cornerstone" funded by Tencent to start the application