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




Freeing Memory In Vbscript


Hi, do you ever have to worry about memory in vbscript?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Freeing Memory
I have recieved a complaint about some code I wrote a while back and it got me to thinking. I am reading information from a file to an array. This takes a while to fill up the array, but I figured after that, referencing the array would be fast. Am I correct in my assumption?

Freeing Memory
I've seen a lot of tools to do this, but most are quite rubbish, with strange popups etc, and no im not looking for a good one, I'm wondering if there is some kind of API to manually free up memory? Or defrag it? Etc...? If not, how. lol.

P.S Using VB.net here.

Freeing Memory With End
If I use the word end to exit my program, will it free all of the memory that the program is using?

ie if I have several objects and several instances of forms, before using the end command, should I set all of them = nothing, or will it automaticaly do this for me?

Freeing Memory
i got the application here working http://www.vbforums.com/showthread.p...22#post1862022
without help from this forum i would not be sure to have done it. Thing is have a problem, As my app is running it just keeps consuming ram till it hangs the pc , are there any common methods to release some memory back to the comp at timed intervals? or at any intervals !!
ty
peace
A

About Freeing Memory
The only reason I can think of why objects and other thingies are not cleared from memory at program exit is to allow people to create memory-resident utilities, is that correct? Otherwise it would seem logical to automatically free all memory that the app has used during its run.

For example, what if DeleteObject is not called after having used SelectObject? Does that mean some memory is tied up? Is it really that serious? Is there some rule to tell which things must be deleted/destroyed at program termination? It's an issue that often confuses me and if I use a call to DeleteObject it's only because I have copied/pasted some code from elsewhere but I don't really know why I'm doing that.

Freeing Memory...
Access

How do I clear or delete memory of a variable?


Example

Global TRYTODELETEME

After using this variable delete every instance of it from your code. Then try recreating that variable as:

Dim TryToDeleteMe

Even once I have removed my global variable from all my code if I try to reuse it the format (All caps) shows up again.

Something like Free(TRYTODELETEME) would be great

Freeing Memory
Is there a way in VB6 to free up used memory like the way MemTurbo does? Thanks

Freeing Memory
I am trying to be as memory conscious as possible with my program. I am defining my variables at the proper levels and not over extending them. My question is when I am done with a form and I “unload” it does it free memory used by other controls like ADO? Or should I unload each control when I am done using it?

Thanks

Freeing The Memory
Hi,

I am using for memory allocation redim() of the array. suppose if
i want to free the memory what should i do?..

see i am having a global 2-D array initialized by arr(0)

in procedure say getArr(row,col) ,where i am determining the
size/dimension i am doing

redim arr(row,col).

for every time if i call the above procedure getarr().. the previous
memory has not been freed( the system tool is saying the memory is still
in use even if i redim for lesser row and col value.

don't suggest me use preserve option.. coz it will help if u extend the
array then it will help. but i am going to shrink the array..



please do help me..

Thanks and regards,
Bala

Memory Freeing
Hi,
Does anyone know how I can force VB to remove a variable from
the memory?
This is supposed to be done by setting in to "nothing", but that doesn't work
(at least not with programs that use large amounts of memory simultaneously.

The objects I've been working with are ADODB.Recordset.
Setting them to "nothing" closes the object, and is also supposed
to free it from the memory completely.
But in fact, this is not done, or is not done fast enough
(my program allocates and disallocates many recordsets in a very short time period).

Thanks in advance,
                             Ami

Freeing Memory In Vbs
Hi, does anyone know how to free memory in vbscript?

thanks

Freeing Memory After API Call
I've read all the threads I can find on freeing memory when exiting
a program but I can't find a solution to my problem.

---

(EDIT: ADDED But Problem persists).

Despite clearing all the controls on my form and then setting my
form = Nothing ( i've tried unload frmMain aswell ) my program remains in
memory when it appears to close.

Set rtbName = Nothing
Dim c As Control
For Each c In frmMain Set c = NothingNext

set frmmain = Nothing


Is my problem caused by having a subclassed RichTextBox -

Public Function WindowProc(ByVal hWnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

If Msg = WM_VSCROLL Then If Not scrollingRTB And connected Then scrollingRTB = True
frmMain.rtbBuffer.Text = ""
frmMain.rtbBuffer.SelColor = vbRed
frmMain.rtbBuffer.SelText = "Buffering..." & vbCr
frmMain.rtbBuffer.Visible = True
Set rtbName = frmMain.rtbBufferEnd IfEnd If

If Msg = WM_NCDESTROY Then Call SetWindowLong(frmMain.rtbMain.hWnd, GWL_WNDPROC, lPrevWndProc)

WindowProc = CallWindowProc(lPrevWndProc, hWnd, Msg, wParam, ByVal lParam)

End Function

...and if so, how can I fix it? And if not, what am I doing wrong?

Any help would be most appreciated.

Thank you.

Freeing Memory... Don't Understand
hi all,

i've got something that may look a stupid question...

when i dim an object like this:

Dim MyVar(1000000) as string

then at the end of the project if i want to free it like this:

Set MyVar(1000000) = Nothing

i get a "object still needed error" even though i'm really not using that variable and it has not been declared public...

What am i doing wrong?

thanks,

w.

Freeing System Memory
How do I free some RAM on a computer?

Do Loop And Freeing Memory
I am using a Do Loop to run a procedure I have created.

Do
Call ValLoop
Data1.Recordset.MoveNext
Loop Until Data1.Recordset.EOF = true




Basically what it does is retrieves the records from the Oracle database, uses the procedure to validate several fields and formats the text and saves the changes, moving on to the next record in the database and repeats the process.
The problem is there are on average 10,000 records each time I want to perform this and it seems to freeze up after it does so many records.
Any ideas on avoiding this?

Dan

Question: Freeing Objects And Memory Leaks
Hi,

I've been working with collections a lot lately and suddenly got to wondering about freeing up objects in a collection.

Noramlly I alway use: ' set objName = Nothing '
when through with an object.

I do the same when done with a Collection object.
' Set CollectionName = Nothing '

The question is should I be setting each collection object = nothing first.

for example:


Code:
Dim objCollect as New SomeCollection
Dim objSingle as New SomeObject
Dim i as integer

for i = 1 to 20
'Set objSingle properties
objCollect.Add objSingle
next i

'Do some work with the Collection

'Is this part required?
'---------
for i = 1 to 20
set objCollect(i) = Nothing
next i
'---------

set objCollect = Nothing

Freeing Dynamically Allocated Memory (RESOLVED)
Hello everybody

When I`m unloading dynamically allocated objetcs in memory I use the statements :


Code:
rsTexnikos.Close
connbio_tech.Close


where rsTexnikos is an ADODB.Recordset object and connbio_tech is an ADODB.Connection object. Do I need to do something else to successfully deallocate the memory? In some source code I was looking at the programmer used :


Code:
rsTexnikos = Nothing


Is this necessary or just a precaution against untimely use of a reference?

thx, in advance

George Papadopoulos

Freeing Variables...
When I declare a variable or object in VB...it allocates memory to store that in correct? Well, how do I erase the variable from memory?

Freeing A DLL Library
Once a Visual Basic program uses a DLL I've made, it locks the file. The problem is that I need to delete the DLL at the end of the program. Is there any way to get the program to free the DLL? I've tried using LoadLibraryEx and FreeLibrary, but couldn't get it working, is there anything wrong with this:

Code:
hDLL = LoadLibraryEx("C:Documents and SettingsBarguastMy DocumentsVisual BasicDBv4db.dll", 0, DONT_RESOLVE_DLL_REFERENCES + LOAD_WITH_ALTERED_SEARCH_PATH)

I can assure you that the filepath is correct. The DLL doesn't have (or particularly need) a DLLMain function, but is that why the function keeps returning 0?

Someone please help with either or both of these questions!

Freeing Up Ram Through Visual Basic
First post, yay

I saw before that it could be done pretty easily through visual basic.

Where can I get code or a .bas file that will let me eg. run

Private Sub Command1_Click()
Freememory(x kilobytes)
End Sub

Someone here has got to know. I have been searching for weeks.

Freeing System Resources
I have written a program on WinNT (PIII processor, 256mb RAM),which searches an Access db every 2 seconds +/- , looking for requests posted by another program. I also have 2 log files and COM1 port open for possible comms to an external system. The program (not running as a service) works perfectly BUT it virtually uses all the system resources (ie. it takes forever to load up MS EXcel or Windows Explorer etc.). How can this be overcome?. Any assistance will be greatly appreciated.

Can I Pass A Parameter To VBSCript And How Can I Get Current Path In VBScript?
Can I pass a parameter to VBSCript ?
How can I get the local path in VBScript?

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,
Brian

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,

Andy

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...

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...

Code:
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
Next
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...my Memory!!
How can you include child command in data report!!

I can't remember how!!

Vbscript Help
Is it possible to get all the list of files from this ftp ?

ftp://ftp.symantec.com/public/englis...ton_antivirus/

VBScript To EXE
Hi All

How Do I convert my VBScript to an executable?

Thanks

~SOLO~

Need Help In Vbscript
I would like to detect whether a text field is clicked in the contact form in outlook, i am toatally new to vb in any form especially vb script, heres what i have:

Sub FullName_Click( )

output something via MsgBox

End Sub

this is all i have and i think the problem is it is not detecting the FullName field as it works fine when i use a command button. I've also tried GotFocus and Enter, like general vb but it didn't work.

Please can you help.

About VBScript {in VB}
Hello all, I'm wondering if its possible to use VBScript in a VB application. For example in a game, where the VBScript files contain the character functions etc, so I dont have to edit the exe everytime I want to change something.
As if VB were interpreting the VBScript.

Thanks in advance.

VB = VBScript?!?!?
Hello,

I don't know if this is the right place for this question
but I'll give it a shot any way, and here it comes, bit silly...

Is the coding language in VB is VBScript or just VB?

VBScript To EXE
Hello,
I codes a VBScript file to generate pdf files dynamiclly and send them out to user's email with CDONTS . It works well. But with low efficient. Now my boss ask to change it into vb exe file.
Can I just create a new project with VisualBasic then paste the code into it?
It errors~
Why?

VBScript
I can't seem to be able to get the Val function to work in vbScript. As in:
Code:
Dim temp
temp = val("123 fake street")
MsgBox temp
I want the temp var to read only the 123. Is there another way to do this when using vbScript?

Thanks,

Tom

VBScript
Can any one give me a good web site on learin VB scripts?

VB6 From VBScript
Just learning VB6 now after previously learning (with a fair working knowledge) VB Script. Will most of the language translate from VBScript to VB6, particularly from the interaction with Access point of view? I understand that I cannot use response.write and many other I am sure but as far as connecting to the database, executing recordsets, etc. can I just copy it over?

Is their such a resource (a book or on the web) that tells me what works in both languages?

VBScript
Hi people, i have this simple vbscript:


Code:
Public Sub Main()

dim FecDesde30, FecDesde90, Fecha


FecDesde30= DateAdd("d", -30, CDATE(Fecha))
FecDesde90= DateAdd("d", -90, CDATE(Fecha))


msgbox "FecDesc30=" & FecDesde30
msgbox "FecDesc90=" & FecDesde90



End Sub

Well,I have a Script Control in VB6 to execute this script.
The variable 'Fecha' is setted from VB with current date (dd/mm/yyyy format).
My problem is, i have the dd/mm/yyyy format and when i use dateadd function
this returns date with mm/dd/yyyy format.
Any solution?
Thanks in advance!
Merry Xmas to all!

VBScript In VB6
Hey is it possible to program in VB6 and then save or convert to VBScript? It seems like it should be possible, but I haven't found a way to do it yet.

Getting The INI Value In Vbscript!
Forgive me all!
I see some great code here for getting INI values in VB. I need to get the value using VBscript. I have tried to modify the VB code, to no avail. Can any one help?

TIA Bill

How To Use VBScript??
What is the differance between regular VB and VBScript? I'm trying to copy a file using 'fsys.copyfile' and I get an error that says I need an object. Are they 2 totally different things? I'm just a little confused. Is there another way I can copy a file and rename it?

I'm learning VB on the job so all this is new to me.

Any help is greatly appreciated 8^)

Thanks!
Joni

Vbscript
Hello,

i need to modify the name of a file to store it because it is over written all the time. I thoucht of having a text file that will store the counter which will then be used to modify the name. after the name is modified, i would like to over write the "new" value of the counter.

the change of file name works fine, but it doesnot work to read the txt file.

Thanks Eric


my attempted code is here:

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim fso, f, val
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:...counter.txt", ForReading)

set val = f.ReadAll

val = CInt(val)
val = val + 1
val = CStr(val)

outFileName = "c:...glue_input" + val + "_ts_h_26_38_5.t0"

f.Close

dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
filesys.MoveFile "c:... mp s_h_26_38_5.t0", outFileName



Set f = fso.OpenTextFile("c:she2001dataskaaruplayercounter.txt", ForWriting, true)
f.write (val)
f.Close

Vbscript
i need help writting a script

i am tryin to write a script that will move logs file to a different location then move a new template of that file to the same folder

VBscript Help..
The below code works like a dream, it copies one file and distributes it to a large number of directories on a shared folder located on our server, it also records the directories it has skipped due to error.

Throughout the shared folder, there is a mix of different Normal.dot templates, some get one and some get another. We differentiate between each user by having a folder in each users directory called either 'Normal' or 'Normal_PM', I use the two versions of this script to do this.

When the script run and updates, it records errors but it also records non-errors due to the file path being different IE

K:Named, FolderDatabasesNormal - Path Not Found (this isn't an error it's just a different file path)

Is there a line of code I can add to this script that can say something like -

If file path is "DatabasesNormal_PM" skip and resume next?


Code:
Dim fso, f, fc, f1, SourceFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set SourceFile = fso.GetFile("K:NoticeboardNormalUpdatesNormalNormal.dot")
Set f = fso.GetFolder("K:")
Set fc = f.SubFolders
For Each f1 In fc

If InStr(f1.Name, ",") > 0 Then
On Error Resume Next
SourceFile.Copy f1 & "Databases
ormal"
If Err.Number <> 0 Then
Select Case Err.Number ' Evaluate error number.
Case 70
mystr = mystr & F1 & " - Permission Denied" & vbnewline 'add to string here
Case 76
mystr = mystr & f1 & " - Path not found" & vbnewline ' add to string here
Err.Clear
Case Else
End Select
Else
End If
On Error GoTo 0
End If
Next

Set F1 = fso.CreateTextFile("K:NoticeboardUpdate Script LogsNormalUpdateScriptLog.txt", True)
f1.Write mystr
f1.Close
Set f1 = nothing
set fso = nothing

VBA To VBScript
I've been trying to develop a File distribution script, with some success, I've managed to get the script to copy one file and then distribute it into the many folders, but now I'd like it to record the folders it has skipped due to errors IE: Error 76 "File path not found". But I can't get it to work, Any suggestions?
Code:
Workbooks.Add
Range("A1").Value = "Folders Omitted"
Range("A1").Font.Bold = True
ActiveCell.Offset(1, 0).Select

Dim fso, f, fc, f1, SourceFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set SourceFile = fso.GetFile("E:Test AreaNormalUpdatesNormalPM
ormal.dot")
Set f = fso.Getfolder("E:Test Area")
Set fc = f.SubFolders
For Each f1 In fc

If InStr(f1.Name, ",") > 0 Then
On Error Resume Next
SourceFile.Copy f1 & "Databases
ormal_PM"
If Err.Number <> 0 Then
Select Case Err.Number ' Evaluate error number.
Case 76 ' "Path not found" error.
ActiveCell.Value = f1
ActiveCell.Offset(1, 0).Select
'LogInformation f1
Err.Clear
Case Else
ActiveCell.Value = f1
ActiveCell.Offset(1, 0).Select
End Select
Else
End If
On Error GoTo 0
End If
Next

Objexcel.ActiveWorkbook.SaveAs("E:Test AreaNoticeboardNormalUpdatesomitted files.xls")
ObjWorkbook.Close

VB && VBscript
Hi, I have some vbscript code that I launch from a vb platform. The script produces some results when ran with the use of Wscript.Echo which produces message box like responses.

How can I retrieve information from a script unto my vb platform hence avoiding the use of Wscript.Echo . Thanks

How To Run A VBscript From VB6
Hi Happy New Year I would be grateful if told how to run vb scripts via the VB6 platform. Thanks

Can VBScript Help Me On This?
Hi

I have an url (xn--9a.com) that is re-directed to another name. When the user enters xn--9a.com, however, I want the other (re-directed to) domain to show in the Browser History List* and not xn--9a.com.

(*The Browser History List is the drop-down box of 25 or so recently visited url's).

So to recap, I am looking for the 're-directed to' url to be shown in the BHL record and not xn--9a.com. Either that, or no url is to be recorded/shown at all.

If you can help, please get in touch with me here or at: richardchaigh@hotmail.co.uk

Regards,

Copyright © 2005-08 www.BigResource.com, All rights reserved