realbasic-nug
[Top] [All Lists]

Windows Memory Leak

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Windows Memory Leak
From: Ola Olsson <oeolsson at enosis dot net>
Date: Wed, 30 Jul 2003 08:27:56 -0700
Somewhere in the RB manuals I read that using directly, a parameter passed to a method can cause a memory leak in Windows. It suggested to immediately assign the passed value to a local variable to counter this unfortunate effect. That is:

// don't do this
sub setFrames(f as integer)
   dim i as integer
   for i = 0 to f
      do something
   next
End Sub

// do this instead
sub setFrames(f as integer)
   dim i,j as integer
   j = f
   for i = 0 to j
      do something
   next
End Sub

Is this true? And if so, should it be safe practice to always assign passed values to local variables?

--
Best Regards,
Ola Olsson

/*******************************************
/** Ola Olsson -- oeolsson at enosis dot net
/** http://www.enosis.net
/** "I learn so I can teach so I can learn."
/*******************************************

---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
.


<Prev in Thread] Current Thread [Next in Thread>