Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Day 026: ERASE
#7
(12-07-2022, 08:18 PM)bplus Wrote:
Quote:Dammit! I was just about to use that as my signature. Now I have to come up with something else. Too bad Steve is busy! [Image: biggrin.png]

"So old I knew better once but forgot."

BTW Minerva was hinting at a memory leak if start Dynamic arrays in subs... does the above test for that?


This is one of those things that is easy to test for and disprove.
Code: (Select All)
_Title "MemCheck"
Print "Open your Windows Task Manager and find the memory usage for this program."
Print "This is the amount of memory you're using prior to a call to foo."
Print
Print "Press ANY KEY..."
Sleep
foo
Print
Print "And this is how much memory you're using after exiting foo."
Print "Press ANY KEY..."
Sleep


Sub foo
    Dim array(1 To 1000) As String * 1000000 '1 million bytes per string element, with 1000 elements = approximately 1GB of memory
    For i = 1 To 1000
        array(i) = String$(1000, "*")
    Next
    Print
    Print "This is how much memory you're using within foo!"
    Print "Press ANY KEY..."
    Sleep
End Sub

Run it, open Task Manager...  Your program will use about 50MB of memory.   Hit any key, you go into SUB foo, and now are using over 1GB of memory.  Hit any key, exit foo, and that memory is now freed.  You're now back down to using the same 50MB of memory as previously.

No memory leak here.
Reply


Messages In This Thread
Day 026: ERASE - by Pete - 12-07-2022, 07:24 AM
RE: Day 026: ERASE - by mnrvovrfc - 12-07-2022, 10:39 AM
RE: Day 026: ERASE - by bplus - 12-07-2022, 05:20 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 05:36 PM
RE: Day 026: ERASE - by bplus - 12-07-2022, 08:18 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 08:31 PM
RE: Day 026: ERASE - by SMcNeill - 12-07-2022, 10:13 PM
RE: Day 026: ERASE - by mnrvovrfc - 12-07-2022, 10:45 PM
RE: Day 026: ERASE - by Pete - 12-07-2022, 10:54 PM
RE: Day 026: ERASE - by sivacc - 06-10-2023, 06:28 PM
RE: Day 026: ERASE - by TerryRitchie - 06-10-2023, 06:31 PM
RE: Day 026: ERASE - by SMcNeill - 06-10-2023, 06:35 PM
RE: Day 026: ERASE - by bplus - 06-10-2023, 06:39 PM



Users browsing this thread: 2 Guest(s)