Results 1 to 4 of 4

Thread: How to Reduce Process Memory? *Solved*

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    How to Reduce Process Memory? *Solved*

    Hey, I've been trying to make a game using pure VB, and obviously one must use many graphics objects. This is just test code, but still, when I debug the program, the memory still goes up to 600-700MB. Graphics objects are created and used very fast as you can see. How can I reduce this? Do I need to dispose of them after being used?

    Thanks!

    ~Nic

    vb Code:
    1. Public Class Form1
    2.  
    3.     Dim DefaultImg As New Bitmap(My.Resources.TestImg)
    4.     Dim T1 As New Timer() With {.Interval = 10, .Enabled = True}
    5.  
    6.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    7.         DoubleBuffered = True
    8.         AddHandler T1.Tick, AddressOf T1_Tick
    9.     End Sub
    10.  
    11.     Private Function LotOfCode() As Bitmap
    12.         Dim Bmp As New Bitmap(800, 600)
    13.         Dim G As Graphics = Graphics.FromImage(Bmp)
    14.         G.DrawImage(DefaultImg, -5, -5)
    15.         G.FillRectangle(Brushes.Red, 5, 5, 15, 15)
    16.         Return Bmp
    17.     End Function
    18.  
    19.     Private Sub T1_Tick()
    20.         Invalidate()
    21.     End Sub
    22.  
    23.     Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
    24.         e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor
    25.         Dim TestImg As Bitmap = LotOfCode()
    26.         Dim ImgPt As New Point(25, 25)
    27.         e.Graphics.DrawImage(TestImg, ImgPt)
    28.     End Sub
    29.  
    30. End Class
    Last edited by NinjaNic; Feb 21st, 2016 at 01:08 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width