473,395 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Release memory used from a buffer

I used the following command to keep ~50Mbytes for a buffer:

Dim inBuf(50000000) As Byte

I used the buffer and now I want to release the 50Mbytes of memory that my
buffer used.
Is there any way to clear the buffer ???

I tried with the following but nothing happend:
Array.Clear(inBuf, 0, 50000000)
inBuf = Nothing

Thanks in advance
Nov 21 '05 #1
2 1009
It's all about the garbage collector: The CLR releases object memory on a
low priority thread, or when it detects the system needs resources.

Just have patience and the memory will be recovered.

Of course if you're like me and you have very little patience, you can call
System.GC.Collect() which will force the garbage collection, although you'll
take a performance hit.
Regards,

Ben

"NetMasker" <ne*******@yahoo.com> wrote in message
news:O%****************@TK2MSFTNGP15.phx.gbl...
I used the following command to keep ~50Mbytes for a buffer:

Dim inBuf(50000000) As Byte

I used the buffer and now I want to release the 50Mbytes of memory that my
buffer used.
Is there any way to clear the buffer ???

I tried with the following but nothing happend:
Array.Clear(inBuf, 0, 50000000)
inBuf = Nothing

Thanks in advance

Nov 21 '05 #2
NetMasker,

Althouhg you can call the GC, does that mean probably only some nanoseconds
and an not wanted performance hit on your program.

An object is released from memory when there is not anymore a reference to
it, or from it, in your case only to it.

Than is important the place where it is created (the place where the address
is)
The queckest it is released in the lowest place of a routine.

\\\
For i as as integer = 0 to 10
dim sb as new stringbuilder()
Next
///
here all the stringbuilder will be quickly released
\\\
Public class mymodule
Public shared sb as stringbuilder
End class
For i as integer = 0 to 10
sb = new stringbuilder()
Next
///
Here at least the last sb stays in memory until the end, while the GC has
more problems with releasing this kind of constructions.

I hope this gives some ideas

Cor
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tron Thomas | last post by:
As part of applying for a programming position at a company, I recently I had submitted some code samples to one of the developers for review. This is the feedback I received: One of his...
12
by: Bardolator | last post by:
I have a stand alone Java application that uses MS SQL Server 2000 and Microsoft JDBC ODBC drivers to access it. Before I run the application, I open the task Manager to monitor the memory used by...
12
by: Jeremy | last post by:
Hi all, I'm getting very confused about how DB2 uses shared memory and I wonder if someone could clarify matters for me, please ? We are running 32bit DB2 V7.2 FP9 under AIX 4.3.3 on a machine...
22
by: xixi | last post by:
hi, we are using db2 udb v8.1 for windows, i have changed the buffer pool size to accommadate better performance, say size 200000, if i have multiple connection to the same database from...
10
by: babak | last post by:
Hi everybody I'm working with a project in embedded Visual Studio 4 and I have a general problem which I hope that somebody can help me with. My problem is the following: My project works fine in...
6
by: bantamweight | last post by:
Hi, I create a project with vs2005 (both c++ and c# are used, sames the problem is about c++) and it working well in Debug version but the result is wrong in Release version. I checked again and...
8
by: Arjan | last post by:
Hello, I have been looking for a couple of days now, but I can't find anything about how to deal with StringBuilder and releasing the memory used by it. When I use stringbuilder, the memory...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
2
by: Lambda | last post by:
I'd like to load a lot of data into a hashtable, when the memory is used up, I'll write the data to a file. I'm trying to use std::tr1::unordered_map to implement that. My question is if I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.