当前位置:网站首页>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》
边栏推荐
- System framework of PureMVC
- Zhou Yajin, a top safety scholar of Zhejiang University, is a curiosity driven activist
- Easycvr cannot be played using webrtc. How to solve it?
- Camera calibration (I): robot hand eye calibration
- NTU notes 6422quiz review (1-3 sections)
- The root file system of buildreoot prompts "depmod:applt not found"
- [knife-4j quickly build swagger]
- EasyCVR平台接入RTMP协议,接口调用提示获取录像错误该如何解决?
- 1.19.11. SQL client, start SQL client, execute SQL query, environment configuration file, restart policy, user-defined functions, constructor parameters
- 程序员上班摸鱼,这么玩才高端!
猜你喜欢
Win11 control panel shortcut key win11 multiple methods to open the control panel
树与图的深度优先遍历模版原理
DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
[ArcGIS tutorial] thematic map production - population density distribution map - population density analysis
1.19.11. SQL client, start SQL client, execute SQL query, environment configuration file, restart policy, user-defined functions, constructor parameters
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
Kivy tutorial of setting the size and background of the form (tutorial includes source code)
视频融合云平台EasyCVR视频广场左侧栏列表样式优化
EasyCVR集群版本添加RTSP设备提示服务器ID错误,该如何解决?
AI landing new question type RPA + AI =?
随机推荐
Digital chemical plant management system based on Virtual Simulation Technology
Introduction to the PureMVC series
NanopiNEO使用开发过程记录
Both primary and secondary equipment numbers are 0
软件测试之网站测试如何进行?测试小攻略走起!
EasyCVR集群重启导致其他服务器设备通道状态离线情况的优化
一图看懂!为什么学校教了你Coding但还是不会的原因...
Common methods of list and map
Win11控制面板快捷键 Win11打开控制面板的多种方法
The easycvr platform is connected to the RTMP protocol, and the interface call prompts how to solve the error of obtaining video recording?
DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
You can't sell the used lithography machine to China! The United States unreasonably pressured the Dutch ASML, and domestic chips were suppressed again
See Gardenia minor
论文上岸攻略 | 如何快速入门学术论文写作
mpf2_ Linear programming_ CAPM_ sharpe_ Arbitrage Pricin_ Inversion Gauss Jordan_ Statsmodel_ Pulp_ pLU_ Cholesky_ QR_ Jacobi
mpf2_线性规划_CAPM_sharpe_Arbitrage Pricin_Inversion Gauss Jordan_Statsmodel_Pulp_pLU_Cholesky_QR_Jacobi
A picture to understand! Why did the school teach you coding but still not
图灵诞辰110周年,智能机器预言成真了吗?
Easycvr cannot be played using webrtc. How to solve it?
[untitled]