|
I don't have time to experiment
I'm going for a buffersize of 256*1024 (and I will let the compiler do the math ), and flushing every iter%16==0. The example I found online had buffersize=255 (equals 255 bytes right?), but it appears to be much faster with a bigger buffersize! It also seems like avoiding flush() is a good idea.
Thanks for helping me out
|
|
|
|
|
I store files as VARBINARY. To write them to disk I use:
using
(
System.IO.FileStream fs
=
fi.Open
(
System.IO.FileMode.Create
,
System.IO.FileAccess.Write
,
System.IO.FileShare.None
)
)
{
byte[] content = (byte[]) ds [ 1 ].Rows [ i ] [ "FileContent" ] ;
fs.Write ( content , 0 , content.Length ) ;
fs.Close() ;
}
The framework/OS can then buffer it as it sees fit.
(fi is a System.IO.FileInfo , ds is a System.Collections.Generic.IList<System.Data.DataTable> )
|
|
|
|
|
But then you use DataTable, doesn't this load everything into memory first?
|
|
|
|
|
Yes, and if that's a concern, just use a DataReader, which I do quite often.
|
|
|
|
|
Forgot to mention it, but yes, it's a big concern.
I'm extracting almost 120GB of files stored in aprox. 400000 BLOBs.
But thanks for suggestions
|
|
|
|
|
I am trying datagridview drag and drop itself for our application . i was tried this code
void dataGridView1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
DataGridView.HitTestInfo info = dataGridView1.HitTest(e.X, e.Y);
if (info.RowIndex >= 0)
{
DataGridViewRow view = dataGridView1.Rows[info.RowIndex];
if (view != null)
dataGridView1.DoDragDrop(view, DragDropEffects.Copy);
}
}
}
void dataGridView1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}
void dataGridView1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(DataGridViewRow)))
{
DataGridView.HitTestInfo hitInfo = dataGridView1.HitTest(e.X, e.Y);
int index = hitInfo.RowIndex;
if (index >= 0)
{
DataGridViewRow baluba = (DataGridViewRow)e.Data.GetData(typeof(DataGridViewRow));
if (baluba != null)
{
dataGridView1.Rows.Add(baluba);
}
}
}
}
I have the index value of DragDrop method is -1. Not get correct value and also get exception in dataGridView1.Rows.Add(baluba); The exception is "System.InvalidOperationException" ...
How can achieve this ... Please help me....
|
|
|
|
|
Dear Friends
I need to convert numeric values to string .
I'm using ASP.net and C# and database is SQL Server 2000
I Need to convert Rs 400 to Rupees Four Hundred only.
I need sample code
with thanks
Kankeyan
|
|
|
|
|
Here[^]
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Sounds like homework; lots of Code Projectors have submitted articles about how to do that.
|
|
|
|
|
Hello,
I need some help for this problem :
My mainform call a modal dialog, which contain a listbox, a multiline text field and a timer.
When user select a line in the listbox, the timer fire. His job is to fit some text ( string var ) into the textbox.
PB : this work fine only when the dialog is maximised or when i call first an other running program. All appp except my main form...strange !
Have anyone some suggestion ? I thanks in advance. Nicolas
nicolas@nsjs.fr
|
|
|
|
|
When you say it does not work, what exactly to you mean? Is there an error? Or can you just not type or something?
When you say i call first an other running program do you mean you activate some other application and return to your app?
|
|
|
|
|
Is the timer event called when the dialog is not modal? I guess the modal dialog block all other threads.
This statement is false.
|
|
|
|
|
What is the Timer supposed to do?
|
|
|
|
|
Hello, thanks for the interest. Is the dialog modal or not, the result is the same. The tick event's job is only to put a string in the multiline textbox. Here my calling code :
gpsInput = new Form5();
gpsInput.TopMost = false;
gpsInput.Visible = false;
gpsInput.ShowInTaskbar = false;
gpsInput.dlgevent += new Form5.infoevent(gpsInput_dlgevent);
this.gpsInput.ShowDialog();
Here the tick events ( the button enable on/Off is only for testing this problem. The ReadPort is normally called and return the string to put into the textbox.
private void timer1_Tick(object sender, System.EventArgs e)
{
if (button2.Enabled == true)
button2.Enabled = false;
else
button2.Enabled = true;
// ReadPort();
}
I dream about ghost...
}
|
|
|
|
|
Hello, thanks to all. I have found a solution. Instead of using VisualStudio toolbox, I create the timer in my code as this lines :
timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Enabled = true;
with a public var timer. All things work perfectly but I don't have understand why the toolbax timer don't work. I found this solution from deusXL on developpez.net forums. Also thanks to him.
Thanks to every body for your time.
Nicolas
|
|
|
|
|
This is a question for GC experts out there:
[Please don't respond telling me to use Dispose, it's not what I'm looking for.]
I'm currently looking for ideas on how to release memory right before a generation 3 garbage collection. Specifically, I have a bunch of objects that all hold the contents of corresponding files on disk. I'd like to hold as many objects as possible in RAM and only release them as more RAM is needed.
The naive approach is to use a Dictionary of WeakReferences. This is what I'm currently doing, but the problem is that some objects never get out of generation 0, and thus are collected and then re-loaded a few seconds later.
So are there any ideas with regard to getting a good estimate of when a garbage collection is coming so I can move unused objects into WeakReferences?
Some constraints:
1 - My deployment scenario is Mono + Linux, so I can't use the Win32 API, hidden CLR functions, COM, ect, ect.
2 - I'm developing with Visual Studio 2005 Pro. I can't afford VS 2008 Pro, and 2005 has some vital threading features in the debugger that VS 2008 express lacks.
modified on Friday, December 4, 2009 5:32 AM
|
|
|
|
|
Not sure if I understood your scenario correctly, but would the dispose pattern be of any use to you?
|
|
|
|
|
No, this has nothing to do with Dispose.
So think of it this way:
I have 100,000,000,000 large text files on disk.
Each time I access a text file, I check to see if it's in RAM. If it is, I just return the pre-loaded string. If it isn't, I load the entire text file into a string and cache the string.
Ideally, I'd like to keep all of the text files in RAM as strings, but, as I have 100,000,000,000 of them, I can't keep all of them in RAM.
I have no idea when I'm going to access the file again, but it might be as soon as a second, or it might be 10 minutes.
The problem is, if I use a dictionary of WeakReferences*, my strings never get beyond generation 0. They get garbage collected too soon, which means that if I access the same file every 2-3 seconds, I have to keep loading it from disk.
Thus, I'd like to know when a level 3** garbage collection is going to happen so I can explicitly release my references to the most unused strings and make room in RAM for newer ones.
* WeakReference: A weak reference lets you hold a reference to an object without preventing it from being garbage collected.
** Level 3 garbage collection: This is a less frequent garbage collection that only occurs when memory is running low.
|
|
|
|
|
|
Like I said, I'm deploying on Mono + Linux, so I can't use COM or CLR-specific APIs.
|
|
|
|
|
GWBas1c wrote: Like I said, I'm deploying on Mono + Linux, so I can't use COM or CLR-specific APIs.
ok, sorry!
All the best,
Martin
|
|
|
|
|
Best thing is to use dispose() pattern to release memory by using below code
dispose()
{
base.dispose();
GC.SuppressFinalize(this)
}
|
|
|
|
|
This has nothing to do with Dispose.
I'm trying to release references right before a garbage collection occurs. It's for a cache that should grow to occupy as much RAM as possible.
|
|
|
|
|
Pls. refers once purpose of Dispose pattern and supressfinalize method of GC.
|
|
|
|
|