每次打开 InGameForm 时,我的表单都会不断创建新对象,这会导致内存使用率过高
我正在开发一个问答游戏。我有两种形式。 Form1 和 InGameForm。从 Form1 中您可以选择大陆游戏模式和分钟。单击“播放”后,InGameForm 将打开。 InGameForm 将资源中的 196 个图像列表加载到 flags 数组中。
Image[] flags = new Image[196] { Properties.Resources.Greece, Properties.Resources.United_Kingdom, ect ect super long line };
问题: 每次我从 ingameform 切换回 form1 并选择另一个或同一大陆,然后单击“播放”时,它都会使用双倍的内存。我怀疑它确实如此,因为我每次都会创建一个新的图像数组而不处理最后一个对象。我能做些什么? form1.jpg InGameForm.jpg
i am developing a quiz game. I have 2 forms. Form1 and InGameForm. From the Form1 you choose continent gamemode and minutes. After y click play InGameForm opens. The InGameForm loads to flags array a list of 196 images from resources.
Image[] flags = new Image[196] { Properties.Resources.Greece, Properties.Resources.United_Kingdom, ect ect super long line };
The problem:
Each time i switch back to form1 from ingameform and pick another or same continent and then click play it uses the double amount of memory. I quess it does because i create a new array of Image each time without disposing the last object. What can i do? form1.jpg InGameForm.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论