Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How To Clear Up Memory?

I has a application that load webpage constantly, but it seems "eat up memory" prety fast after. Is there a way to clear up memory after each time loading? Thanks

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Memory Leak Problem, How To Clear Memory?
Does anyone have code to clear memory?

My program dies after a while of usage, i need to clear the memory after each process.... hrm...

Clear Memory
is there a way to write a VB app that could clear the memory form the PC?

Clear Memory
I'm using a user document. I know there r some memory leaks when I terminate the program. How will I prevent his? In normal form document I use set form1 = nothing and it works...

Thanks and always love VB

Is There A Command To Clear Memory ?

I have an application that uses 3rd party objects to retrieve images from a FileNet server. There is a memory leak in the 3rd party code that does not release memory when the retrieval process is complete and eventually hangs the machine.

The application runs around the clock and runs the retrieval process at whatever time is scheduled by the user.

Even shutting down the application does not free up the memory, the PC must be rebooted.

Does anyone know of a command or API that might help clear out the memory ?

Thanks for any info.

Clear Memory And Cache - Please HELP!!
Dear all,

I would like to be able to write a pgram which just, at a click of a button clear memory and cache.



Clear Object From Memory While Using It?
I have a VB6 program solution thats really bugging me. I have a main form that has a CreateSubFrm button which create an instance of a sub form if there is not one created already. On the Sub form is a Exit button which unload itself. After clicking the Exit button on the sub form (it unload and disappear) the CreateSubFrm button on the main form do not work any more. The reason is the object (objx) of the sub form is still in memory and exist, so when u click the CreateSubFrm button again the IF statment is NOT true that objx = Nothing and will not let you create the objx.

The way I got around this is to raise an event in the sub form and set objx = nothing in the main form.

Now this seem to me a really untidy solution. Does anyone out there know the proper way of solving this solution??????

Below is the code.

Main form:
Private objx as frmSubForm

Private Sub cmdCreateSubFrm_Click()
    if objx is nothing then
         set objx = new frmSubForm
End Sub

Sub form:
Private Sub cmdExit_Click()
     Unload Me
End Sub


How To Clear Autoredraw Image From Memory ?
I have a MDI form which might load maybe a 20 or 30 MDI documents at the same time. The MDI form that's loaded multiple times, have picture boxes which autoredraw properties is set true. This is the fastest way i can implement a flickerless output. (You may advice back buffering in memory and BitBlt it to screen, i tried and it's not fast as Autoredraw).

Anyway, it's OK when only 5 or10 MDI documents loaded but after 10 or 15 it says that "Autoredraw image can't be created". I think it's getting out of GDI memory.

As you see, i just use Autoredraw just for back buffering (for flickcerless output). After my drawing is done i want to get rid of the buffer image (clear form memory) that VB creates when autoredraw is set to true. This is where i want your help.

Thanks for your interest...

How To Clear Values From The Memory At Run Time?
Hello friends

I have a problem with this programme. I use the input value from the text box I have on the form......'' q = frmMain.Text8.Text"

My problem is after I did the first anlysis and want to do a different analysis for different value I get the same result i.e. my program use the first value I use in the first analysis.

Is there any mechanism that I will use to clear the previous value from the text box at run time and use different value.


Clear A Document In Printer Memory

I use vb printing in my project and I use printer.print method, it's
success. Now I want to know how can I cancel a document in the prnter
memory. I mean when I press the print button when there is no papers in the
printer (after execute printer.enddoc it sends spool to printer) I need to
cancel that document after a time period. how can I over come this. Please
help with sample code. this is an imediate requirement. please....



This email and any attachment hereto is for authorised use by the addressee
only. It may contain confidential or priviledged information and/or
proprietary material. If you are not the intended receipient , this email
and/or any information it contains should not be copied, disclosed,
retained or used by you or any other party, and the email and all its
contents should be promptly deleted fully from your system and the sender
informed. Thank you.

Clear Nested Array Structure Memory
I've I several structures which are arrays and which are nested under a single structure (call it Top) which is also an array.

It appears (???) that by erasing Top, that the rest of the array structures still exist and remain in memory (Getting Out of Memory Error).


Does anyone know whether:

1) Just erasing the Top array structure will clear all underlying (nested) array structures?
2) Each array structure must be erased independently?
3) How to verify whether the structures still exist in memory?


How To Clear The IE Cache Memory Automatically While I Shut Down My Pc?
To empty internet cache:

goto search for FindFirstUrlCacheEntry

[SOLVED] Clear/Remove From Memory A Recordset Variable
Hi, my question is this. Is there anyway to remove/clear an entire variable(record set) from memory without having to go through and define each part of the type as = "" or = 0? Here is my record set if that helps any


Public vMatch As matchTypeRecord
Public fpMatchDB As String
Public numMatchDB As Integer
Public MatchDbId As Integer

Public Type wepLocType
 name As String * 20
 winningObject As Byte
End Type

Public Type TransitionType
 transitionText(1 To 3) As String * 95
End Type

'-Location Type
Public Type locType1
 name As String * 50
 transitionLoc(1 To 10) As TransitionType
 Weapon(1 To 9) As wepLocType
 pinfall As Byte
 submission As Byte
 canTag As Byte
 countOut As Byte
 dq As Byte
 canFight As Byte
 winLoc As Byte
 onTopOfWep As Byte
 onWeapon As String * 20
 onWeaponLocation As String * 50
 ground As String * 50
End Type

Public Type TweakType
 noDq As Byte
 noCountOut As Byte
 TimeLimit As Byte
 TimeLimitVal As Integer
 numFalls As Integer
 winPin As Byte
 winSub As Byte
 winMatchCall As Byte
 winLocation As Byte
 elimination As Byte
 winBlood As Byte
 winThroughObject As Byte
 multiFall As Byte
End Type

'-Main Index
Public Type matchTypeRecord
 name As String * 50 'Also file path
 Location(1 To 10) As locType1
 iParticipants As Integer
 iGroups As Integer 'up to 6
 groupDistribute(1 To 6) As Integer 'Distribution of groups ie 1v1, 1v2 ect
 Tweaks As TweakType
End Type

I want to be able to set vmatch = "" so that it clears all the info out of the variable...if that makes any sense. If not please ask and I will try to clarify further. Thanks for any help in advance.


Edited by - Strife03 on 8/14/2004 12:59:26 AM

Uload Everthing And Stop All Loop Timer And Clear Memory
What is the best way to unload all of the forms, but still clear the memory and stop all loops?

Script That Will Clear Cookies/click A Button/clear Cookies...
Hi everyone, my Visual Basic knowledge is minimal. I used VB when its latest version was v6 long long ago... (2002-2003) And I was only able to create basic applications.

Now I need a script (or whatever that will do the job) to do this:

- Clear cookies in my browser
- Click a checkbox
- Click a button

I want something that can do this over and over again. I'd be really really glad if you could explain it in detail or give me some document links about it. Thanks in advance.

Shared Memory File - Memory Leak (URGENT)
I use a Shared Memory File, for caching data. With an ActiveX dll my applications read certain data out of the memory file.

When creating the ActiveX Object, the dll accesses the memory file in the Class_Initialize function, unmaps and closes the handle in the Class_Terminate function. After work, the Object is destroyed (Set Object = Nothing).

Whenever calling the CopyMemory API...

VB Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, Source As Any, ByVal bytes As Long)

...from the ActiveX dll to read data from the shared memory, the used memory of the application that created the object, rises for exactly the lentgh of bytes read by the CopyMemory function, and is never released. Not even if the object is destroyed.

thanks for a fast answer.

Memory Unable To Be Read - Can VBA Perform A Memory Drop
Forum readers,

While running some of my more memory-intensive VBA macros, the program sometimes crashes because "memory unable to be read." Is there a VBA command to dump memory in between sections of my macro so it does not use up too much memory at once? I've used "Application.Wait Now + TimeValue("00:00:05")" as a way to pause the macro in between sections but I'm hoping there is a way to clear the computer's memory.

Thank you,

BitBlt: Desktop To Memory, Memory To Picbox
I'm very new to this BitBlt thing, and to graphics in general - Excel gal venturing outside VBA - so please keep your explanations on a newbie level.

I wanted to learn BitBlt, so I thought I'd write a screenshot maker and try some different approaches to see how it all works. Three out of the four things I tried work as they should. The fourth one doesn't work at all, and I cannot see why. (All four are in the attachment.)BitBlt from desktop DC to picturebox DC. That works, except it doesn't update when I resize the form and the picbox, but I understand why it doesn't, so that's fine.BitBlt from desktop DC to a memory DC and from there to picbox DC. Re-BitBlt from memory DC to picbox DC whenever the picbox is resized. This is the one that fails completely.Resize the picbox to screen size, then BitBlt from desktop DC to picbox DC. Works fine.BitBlt from desktop DC to memory BMP, copy from BMP to clipboard and from clipboard to picbox. Works fine.Since I have 2 fully workable approaches (thanks to Deadalus who helped me get this far!) I'm kind of OK, but it bothers me that I can't see why the last remaining one doesn't work. I'm probably overlooking something simple, but would appreciate help figuring out what it is.

Memory Store && Memory Recall In Calculator.
Hey guys, for a project i am required to create a relatively basic Calculator. I have got the calculator with basic features, including Squared and Square root. To finish it off sufficiently i need to use Memory Store and Memory Recall functions. Now this is totally over my head, can anyone give me a pointer as to what i need to be looking at?

Many thanks,


Strange Memory Leak With Memory DC
Hi, all

I'm using a memory DC to paint an image before i update the image to the screen. I use a timer to keep the image updating like this...

Private Sub tmr_Timer()
With cIP.Draw(cDC.hdc)
.Rectangle 0, 0, cDC.Width, cDC.Height, 0, vbWhite, vbWhite
If UBound(cTXT) > 0 Then
Dim A As Integer
For A = 1 To UBound(cTXT)
.Blt cTXT(A).x, cTXT(A).y, cTXT(A).Width, cTXT(A).Height, cTXT(A).hdc, 0, 0, BLT_AND
End If
End With

cIP.Draw(P.hdc).Blt 0, 0, cDC.Width, cDC.Height, cDC.hdc, 0, 0, BLT_STD
End Sub

It runs fine for a while but then the graphics that im storing in my memorydc are bleeding on to either the VB IDE when im working in there or on to the desktop when i'm running my binaries.

Any ideas?

Lack Of Memory!!
How can you include child command in data report!!

I can't remember how!!

Clear All
I'm trying to Clear everything from my labels and ComboBoxes at the press of a button.

I'm fairly new to VB so have just been plodding along using 'Trial and Error'

This is the ciode that i have 'developed'

Private Sub cmdClear_Click()
lblOhms.Caption = ""
Combo1.ListIndex = ""
Combo2.ListIndex = ""
Combo3.ItemData(Combo3.ListIndex) = ""
lblFirst.BackColor = ""
lblSecond.BackColor = ""
lblMultiplier.BackColor = ""

End Sub
but i doesn't seem to work. Could someone please point me in the right direction

Many Thanks

Help Me Clear This Row Up. What Is Better VB Or C++
Hi i am having a row with this programmer who thinks C++ is the best language around. An VB is a pile of rubbish made out of C++

From what I know and have read alot of experts slate C++ as prehistoric and long winded.

Can someone give me their opinion please./


Still Not Quite Clear
What is the difference between Private Sub, and Private Function, also what is the difference between form module and code module. Regarding VB 6.0, and the concept of Recursion.

Is there anyway to clear all textboxes from user inputed text on a form without writing code for every textbox?

Clear UDT
Is there an easy way to clear a UDT? For example:

Public Type This
A As String
B As Integer
C() As String
End Type
Public That As This
Public Sub Stuff()
That.A = "Hello"
That.B = 9
ReDim That.C(1)
That.C(1) = "GoodBye"
End Sub

How do you clear "That"? Do you have to manually reset each element? Thanks in advance!!!
Hello, im fairly new at vb and am working on a gameshow format program where if you answer one question correctly it moves to the next. I know how to do the if thens with the option boxes, but i was wondering, how would i clear the screen if they got it right and have it bring up the next question?


Clear Db
Which command sould I give to clear all the records from all fields of a given database?


Clear This To Me ?
I read this on the vbLibrary but i dont get it
please explain this to me more clearly and can you give me an example how to use it

UBound ?
LBound ?
CInt ?
lngResult As Long ?
outstr$ ?
CLng ?
Replace ?
vbNullString ?
tmp ? ? ?
tmpNum ? ? ?
tmpStr ? ? ?
Split ?
difference between Left and Left$ ?
difference between Right and Right$ ?
what is the difference between Mid and Mid$ ?

Please Explain it !

Clear CBO
Hello to all,

I populate a combo box and its style is set to (1 -simple). How can I clear the textbox but still retains the data in the combo box.

I tried combobox1.listindex=-1 but it does not work


I Am Probably NOT Being Clear!
why is this query not returning me the number of times the SecID is found in the DB? Look at the link below and see the result set. See how if there are 2 or more SecID that the count next to it doesn't actually count it?

SELECT TOP 100 PERCENT dbo.Response.QuestionID, dbo.Sections.SectionName, dbo.Questions.QuestionText, dbo.Response.ResponseText,
dbo.Questions.Published, dbo.Users.FirstName, dbo.Users.LastName, dbo.OtherResponse.ResponseText AS OtherResponse,
dbo.Questions.SectionID, COUNT(dbo.Questions.SectionID) AS SecIDCount
dbo.Response ON dbo.CJQDetail.ResponseID = dbo.Response.ResponseID AND dbo.CJQDetail.ResponseID = dbo.Response.ResponseID INNER JOIN
dbo.Questions ON dbo.Response.QuestionID = dbo.Questions.QuestionID INNER JOIN
dbo.Sections ON dbo.Questions.SectionID = dbo.Sections.SectionID LEFT OUTER JOIN
dbo.OtherResponse ON dbo.Response.ResponseID = dbo.OtherResponse.ResponseID CROSS JOIN
GROUP BY dbo.Response.QuestionID, dbo.CJQDetail.CJQID, dbo.Questions.SectionID, dbo.Sections.SectionName, dbo.Questions.MinResponse,
dbo.Sections.FormID, dbo.Sections.AspPageNum, dbo.Questions.QuestionText, dbo.Response.ResponseText, dbo.Users.UserID,
dbo.Questions.Published, dbo.Users.FirstName, dbo.Users.LastName, dbo.OtherResponse.ResponseText, dbo.Sections.SectionID,
HAVING (dbo.CJQDetail.CJQID = 5) AND (dbo.Sections.FormID = 1) AND (dbo.Users.UserID = 4)
ORDER BY dbo.Sections.SectionID, dbo.Response.QuestionID

I have 5 textbox from text1 to text5 i have a button of
clear wht i want is to clear text box if my foucs is on text3 i
want to clear that text not other is it possiobe to do like


How Do You Clear A Db?
Every time I need to use my db, new info needs to be written to it. So all the old info has to be erased. How do you erase a whole access db though?

On A Clear Day....
Does anyone know if you can make a form (not a control) transparent so only what is on it (like a picture) shows up over any other forms which may be on the screen?

Clear A From
i have various forms in my database that as I select a project, will fill all the field on the form.

Rather than writing

FieldA= ""
FieldB= ""
FieldC= ""
FieldD= ""

etc etc

everytime I have to clear the form, I thought I would write a function, where I passed in the form name, and then clear the fields, sort of like this

Public Sub ClearForm(strFormName As String)
    Select Case "strFormName"

        Case "frm_Main":
            frm_Main.fieldA= ""
            frm_Main.fieldB= ""
            frm_Main.FfieldC= ""

        Case "AnotherForm":
            AnotherForm.fieldA= ""
            AnotherForm.fieldA= ""
            AnotherForm.fieldA= ""
    End Select

End Sub

and then from the calling form

Call ClearForm(

for some reason the, although is the name of the form, doesn't pass it to the clearform sub because it doesn't recognise it in the select case statement

can anyone give me a clue as to why it is doing this

Many Thanks

Hey all,
Im just wondering about a .clear method in VBA.As in Code:fsheet.clear.Does this method exist?From what version of excel on is it in.Is there anything equivalent I can do if my version of Excel doesnt have the method in it.thanks.

Clear A PictureBox
If I load an image (in this case a bitmap) into a PictureBox and then use PictureBoxName.cls the image stays the same and doesn't disappear. Its probably some thing very simple. (Btw 'AutoRedraw' is set to 'True'). Thanks.

Clear Txt File?
Is there a command that deletes all text of Input #1..

all text in the opened txt file.


Clear Pictures
How can I make certain colors of an image transparent? I already got the form transparent but now I need to get rid of the edges on some pictures i loaded in, Or is there a skin module out there that would make this process smoother.

Clear Button For Tic Tac Toe
I am having a dilemna regarding my coding for my clear button in a tic tac toe game that I have created. I want it to clear the screen so that another game can be played. Unfortunately, the way it is now is when you click the clear button right now you get the message box that we created coming up and saying you win. It clears the screen but only after you click ok for the msgbox 3 times.

Could someone take a look at the .frm and .vbp files I have provided a link to and let me know how to fix this? Thanks

Tic- Tac- Toe Code

Clear Data?
im using winsock and i want to send two SEPARATE blocks of data... this is basically what i have

winsockDialog.SendData "hey"
winsockDialog.SendData "sup"

BUT!!!!! with the Private Sub winsockDialog_DataArrival, it sticks em together! how can i fix this?


Clear A Surface
how would i clear a surface? like in a VB form "cls"

How Do You Clear Out An OLE Container?
I have linked a word document to an OLE container to display its contents. I want to be able to clear the control so that it nolonger displays the document. I have tried a few of the usual things (.action = , .close etc..) but nothing seems to work with a linked document.


Clear Clipboard
Hallo everyone,
I have a document where I have to paste several images, after coping and pasting some of the images the paste command do not function anymore.
I would like to clear the clipboard but I don't know how.
I try to generate a macro calling the office clipboard and "Clear all" but the macro give me only the WordBasic.EditOfficeClipboard command, but not the clear all.
Could you help me?

Err.clear Does Not Work
I have the following routine:

For i = LM To 12 Step 1


On Error GoTo ErrorHandler

Cells.Find(What:=FindWord, After:=ActiveCell).Activate

Next i

Exit sub
i= i +1
Goto resumei

End sub

The error handling routine works fine the first time, but the second time, it gives me run-time error 91. I belive that the problem is that err.clear is not working, since err is not reset it stops the macro from running when a new error occurs. I have tried to used err.clear in the past and it never works for me. I am using VB 6.0. Any sugestions.


Clear All Textboxes
On a user forn i want to clear all textboxes. Therefore i tried something with "OLEObjects ("Textbox" & i)". That's not the trick.

I want to find a way to loop through all textboxes on the userform.


Clear Checkedlistbox
clear checkedlistview without clearing all items from the listview, basically whenever I hit save have it reset all the checked items back to unchecked.

Collection Clear
i Have a collection with many items. how would i use a codo to remove all the items.


Clear All Textboxes
I have 4 textboxes like this:

Rubies |__________|

Diamonds |_________|

Emeralds |___________|

Crystals |__________|

(button)Total |__________|
its basically a calculater this is the code:
Private Sub Total2_Click()
rubie = Val(Rubie1.Text)
diamond = Val(Diamond1.Text)
emerald = Val(Emerald1.Text)
crystal = Val(Crystal1.Text)
trubie = rubie * 10500
tdiamond = diamond * 5600
temerald = emerald * 4200
tcrystal = crystal * 560
Total3 = trubie + tdiamond + temerald + tcrystal
Total1.Text = Str$(Total3)
End Sub
its a pretty simple code but now i want to add a button that erases all of the values to like start over so all of the text boxes are empty. instead of the user having to go and erase everything.
Anyone know what to do?

UserForm Clear
I have built a userform for entering data into Excel.

I have a couple of questions.

When I click OK the form doesn't clear out the data so that I can
start a new entry, is there something I can do about that?

Also I have a command button to open the worksheet,
but I would rather have it auto open, but if the user has no data
they can click cancel and view the sheet.

Any help would be great. Thanks

Copyright 2005-08, All rights reserved