VB.NET out of memory exception

我与影子孤独终老i 提交于 2019-12-11 16:06:35

问题


This is my code to populate a flow-layout-panel with pictureboxes :

  For Each fi As FileInfo In New DirectoryInfo(Application.StartupPath + "\data\img\em_sml").GetFiles()
        Dim pbx1 As New PictureBox
        pbx1.Width = 32
        pbx1.Height = 32
        pbx1.BackColor = Color.Azure
        pbx1.Image = Image.FromFile(fi.FullName)
        AddHandler pbx1.Click, AddressOf pbx1_click
        FlowLayoutPanel1.Controls.Add(pbx1)
    Next

Suddenly i am getting out-of-memory error in the following line :

    pbx1.Image = Image.FromFile(fi.FullName)

Why ? and how to fix it ?

Don't know if this is relevant or not, but the problem never occurred when i was using 4 gb ram, yesterday i removed a 2 gb ram stick from my pc, now my pc runs on 2 gb ram. Till yesterday, this error was not there, but now this error appers. Does it have anything to do with RAM ?

来源:https://stackoverflow.com/questions/47448680/vb-net-out-of-memory-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!