|
Good Day,
I am using BinaryFormatter to write my own file. The Formatter takes a STRUCT that I constructed and convert it to a byte array that I can write as file. However, for some strange reason, when the FILE is too large (200MB+), I get an out of memory exception. Here's the code:
public static byte[] RawSerialize(object anything)
{
MemoryStream Stream = new MemoryStream();
BinaryFormatter BF = new BinaryFormatter();
BF.Serialize(Stream, anything);
byte[] Data = Stream.ToArray();
return Data;
}
Please note that I have 3GB ram on my system and when the OOM error was called, my memory usage was only 20%.
Is there any workaround for this?
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
Instead of dealing with in-memory byte arrays and streams, why not utilize the hard drive as the backing store stream? This way you won't have to load 200+ MB into memory.
Tech, life, family, faith: Give me a visit.
From my latest post: "It's sobering to watch: the whole country stops for 2 minutes as a siren is blast to remember the 22,437 victims of terror and soldiers who died in defense of Israel..."
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Thanks for the reply Mr. Himango,
Can you please give a detail example or a link on how to accomplish such task? Or maybe just a hint.
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
void SaveObjectToDisk(object objectToSave, string fileName)
{
using(FileStream file = File.Create(fileName))
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(file, anything);
}
} You'll want to look at MSDN for more info, they cover file I/O in great detail.
Tech, life, family, faith: Give me a visit.
From my latest post: "It's sobering to watch: the whole country stops for 2 minutes as a siren is blast to remember the 22,437 victims of terror and soldiers who died in defense of Israel..."
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Hi all,
I have a dataset DsA and 1 datagridview DgvA . I have bind a dataset into DgvA and also add a combobox into DgvA accroding data in DsA .
I would like to know how can i refresh the comboBox in DgvA when DsA was edit?Below is the senario,
1)DsA have 5 rows and values are {a,b,c,d,e}
2)Add comboBox (which according data in DsA) to a datagridview
3)Add 5 rows in datagridview and a comboBox's value is select for each row ,as:
row 1: a
row 2: b
row 3: c
row 4: d
row 5: e
4)Edit row's value in DsA, now will be {W,X,Y,Z,Q}
5)Refresh value in datagridview will get the result as:
row 1: W
row 2: X
row 3: Y
row 4: Z
row 5: Q
Any tips/idea/related source are welcome.
Note: i will not only edit row in DsA, but also will add/delete row in DsA
Here is the exception which i get when DsA changed:
The following exception occured in the datagridview:
system.ArgumentException: DataGridViewComboBoxCell value is not valid
To replace this default dialog please handle the DataError event.
thanks in advance.
regards
cocoonwls
modified on Tuesday, May 20, 2008 11:09 AM
|
|
|
|
|
I was figure out how to do it in my application. Thanks for who have been view my question.
|
|
|
|
|
Hi All,
I want to convert text files (.doc,.txt..rtf) to pdf files using C#.Net.
if any one knows please send me the solution or how to do it.
Thanks in Advance
|
|
|
|
|
Asking someone to send you the code is a poor etiquette in programming forums.
The answer to your question is quite easy if you know how to use Google. Search for DOC to PDF converter. I know there are at least 1 open source tool and at least 4 commercial tools that do this.
Tech, life, family, faith: Give me a visit.
From my latest post: "It's sobering to watch: the whole country stops for 2 minutes as a siren is blast to remember the 22,437 victims of terror and soldiers who died in defense of Israel..."
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Sophia Rekhi wrote: I want to convert text files (.doc,.txt..rtf) to pdf files using C#.Net.
As far as I know you would have to do a COM interop for this..
|
|
|
|
|
Hi All,
I am new to sharepoint concept. I am deploying custom webparts in to my sharepoint site. I deployed it using STSADM.exe but cannot group it into different categories. Can any one help me in this regard.
Expecting your reply
Cheers
Mani.
First have the WILL then u WILL
|
|
|
|
|
Don't cross post
led mike
|
|
|
|
|
under which topic should i post this question....
First have the WILL then u WILL
|
|
|
|
|
What is the .NET 3.5 redistributable package..
Does it contain the whole library needed to run any app??
I am planning to build an application in .NET which would require the framework obviously and when I ship this to client then I would have to ship the .NET framework too for it to run..
My question is that is the .NET 3.5 framework redistributable package which is freely downloadable on Microsoft site enough for shipping with my client application??
Since the size of the package is only 2.73MB, will the whole framework be installed with this redistributable package and would this be enough for my app to run??
One possibility may be that the client may not have an internet connection.. So would shipping this redistributable package be enough or does the client have to download the framework from internet after installing this 2.73MB package??
Please reply..
Thanks..
|
|
|
|
|
Hey,
Not sure, because I haven't deployed 3.5 stuff yet, but I think there's one with Windows SDK 6 (the one installed automatically with VS 2008).
Should be somethere here if you have VS 2008 installed: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFX35
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
I've got a feeling that that 2.73MB installer is simply a bootstrapper which downloads the rest from the internet. At the moment the current framework weighs in at about 300MB, with SP1 (beta at the moment) Microsoft will be introducing a "cut-down" version (i.e. it excludes all the server stuff) which will bring the redistributable size back down to a few tens of megabytes.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Hello,
please, I don't know exactly, when/in which moment of my code execution is a customAttribute constructor of MyCustomAttribute:System.Attribute class called/activated...
I'd like use customAttributes on my methods and based on attribute parameters those methods will be called/executed or not.
thanks,
Peter
|
|
|
|
|
petermeter wrote: please, I don't know exactly, when/in which moment of my code execution is a customAttribute constructor of MyCustomAttribute:System.Attribute class called/activated
Are you using Visual Studio? Do breakpoints not work for you?
led mike
|
|
|
|
|
Yes, 2008 version.
I discovered that the attribute constructor is activated/initiated when I enumerate attributes of MyMethod...
[Security("Admin")]
public void MyMethod()
{
... Attribute.GetCustomAttributes(....., typeof(....))
...method body
}
but I'd like activate/initiate attribute constructor without MyMethod body modification by .GetCustomAttributes...
and therefore I'm asking - exist a way how to perform custom attribute constructor automatically ?
[Security("Admin")]
public void MyMethod()
{
...method body
}
thanks,
Peter.
|
|
|
|
|
It shouldn't matter. But more detail on what you're trying to accomplish might be helpful.
|
|
|
|
|
Hello everyone,
I want to learn from your advice about how to design data structure in the following scenario to be most efficient.
One thread will create data (composed of ID and content), and output to a queue or something (data structure could be chosen to make the scenario more efficient), the data created is very frequently working to produce data, another thread is responsible to aggregate data (for the same ID, aggregate the content and output to a file), and aggregation thread works less frequently -- sleep 10 minutes, aggregate and then sleep again.
I am going to find a solution which could balance,
1. Less performance impact to the data creating thread;
2. To make data aggregation thread works as efficient as possible and consume less memory.
Any advice about how to design data structures?
Currently,
- I am stupidly using a List, appending data by the data creation thread, and I think appending data to the List is less performance impact to data create thread than using Dictionary to insert. Am I correct?
- Read data from begin to end of another thread -- using ID as key into a Dictionary, since there maybe duplicate ID, so when I insert into the Dictionary, I will check if contains key, if yes, I will update the data, or else insert a new one;
- Using lock on the whole List to make thread safe. Does the lock on the whole List is too heavy?
Any smarter ways?
thanks in advance,
George
|
|
|
|
|
I am thinking this would be better done with a database. Databases have built in functions for maintaining ID's. They also have functions for aggregating the data in most ways you can think of.
|
|
|
|
|
Thanks Christian,
Is there a built-in data structure like MuitlMap in C++, which allows one key maps to multiple values in C#?
regards,
George
|
|
|
|
|
|
Thanks Christian,
If not using database, any ideas about what is the best solution you could have with memory based data structures?
regards,
George
|
|
|
|
|
Can anybody give me the sample code for this.
program that takes as its first argument one of the words 'sum,' 'product,' 'mean,' or 'sqrt' and for further arguments a series of numbers. The program applies the appropriate function to the series.
Requires basic control flow, basic operators, and the math library. (Complex numbers available?)
What are arrays like?
What about parsing / implicit conversion?
Are functions first-class (availability of Map() and Apply())?
Error handling: What happens on invalid data?
Free sample codes are here http://allabout-dotnet.blogspot.com
|
|
|
|