I have a fairly simple C# program that just needs to open up a fixed width
file, convert each record to tab delimited and append a field to the end of
it.
The input files are between 300M and 600M. I've tried every memory
conservation trick I know in my conversion program, and a bunch I picked up
from reading some of the MSDN C# blogs, but still my program ends up using
hundreds and hundreds of megs of ram. It is also taking excessively long to
process the files. (between 10 and 25 minutes). Also, with each successive
file I process in the same program, performance goes way down, so that by the
3rd file, the program comes to a complete halt and never completes.
I ended up rewriting the process in perl which takes only a couple minutes
and never really gets above a 40 M footprint.
What gives?
I'm noticing this very poor memory handling in all my programs that need to
do any kind of intensive string processing.
I have a 2nd program that just implements the LZW decompression
algorithm(prett y much copied straight out of the manuals.) It works great on
files less than 100K, but if I try to run it on a file that's just 4.5M
compressed, it runs up to 200+ Megs footprint and then starts throwing Out of
Memory exceptions.
I was wondering if somebody could look at what I've got down and see if I'm
missing something important? I'm an old school C programmer, so I may be
doing something that is bad.
Would appreciate any help anybody can give.
Regards,
Seg 2 2039
Segfahlt <Se******@discu ssions.microsof t.com> wrote: I have a fairly simple C# program that just needs to open up a fixed width file, convert each record to tab delimited and append a field to the end of it.
The input files are between 300M and 600M. I've tried every memory conservation trick I know in my conversion program, and a bunch I picked up from reading some of the MSDN C# blogs, but still my program ends up using hundreds and hundreds of megs of ram. It is also taking excessively long to process the files. (between 10 and 25 minutes). Also, with each successive file I process in the same program, performance goes way down, so that by the 3rd file, the program comes to a complete halt and never completes.
I ended up rewriting the process in perl which takes only a couple minutes and never really gets above a 40 M footprint.
What gives?
It's very hard to say without seeing any of your code. It sounds like
you don't actually need to load the whole file into memory at any time,
so the memory usage should be relatively small (aside from the overhead
for the framework itself).
I'm noticing this very poor memory handling in all my programs that need to do any kind of intensive string processing.
I have a 2nd program that just implements the LZW decompression algorithm(prett y much copied straight out of the manuals.) It works great on files less than 100K, but if I try to run it on a file that's just 4.5M compressed, it runs up to 200+ Megs footprint and then starts throwing Out of Memory exceptions.
I was wondering if somebody could look at what I've got down and see if I'm missing something important? I'm an old school C programmer, so I may be doing something that is bad.
Would appreciate any help anybody can give.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
"Segfahlt" <Se******@discu ssions.microsof t.com> wrote in message
news:0D******** *************** ***********@mic rosoft.com... I have a fairly simple C# program that just needs to open up a fixed width file, convert each record to tab delimited and append a field to the end of it.
The input files are between 300M and 600M. I've tried every memory conservation trick I know in my conversion program, and a bunch I picked up from reading some of the MSDN C# blogs, but still my program ends up using hundreds and hundreds of megs of ram. It is also taking excessively long to process the files. (between 10 and 25 minutes). Also, with each successive file I process in the same program, performance goes way down, so that by the 3rd file, the program comes to a complete halt and never completes.
I ended up rewriting the process in perl which takes only a couple minutes and never really gets above a 40 M footprint.
What gives?
I'm noticing this very poor memory handling in all my programs that need to do any kind of intensive string processing.
I have a 2nd program that just implements the LZW decompression algorithm(prett y much copied straight out of the manuals.) It works great on files less than 100K, but if I try to run it on a file that's just 4.5M compressed, it runs up to 200+ Megs footprint and then starts throwing Out of Memory exceptions.
I was wondering if somebody could look at what I've got down and see if I'm missing something important? I'm an old school C programmer, so I may be doing something that is bad.
Would appreciate any help anybody can give.
Regards,
Seg
That's really hard to answer such broad question without a clear description
of the algorithm used or by seeing any code, so I'll have to guess:
1. You read the whole input file into memory.
2. You store each modified record into an array of strings or into a
StringArray, and write it to the file when done with the input file.
3. 1 + 2
.....
Anyway you seem to hold too much strings in memory before writing to the
output file.
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Franklin Lee |
last post by:
Hi All,
I use new to allocate some memory,even I doesn't use delete to release them.
When my Application exit, OS will release them.
Am I right?
If I'm right, how about Thread especally on Solaries OS?
This means that I use new to allocate memory in one Thread and doesn't use
delete to release them.
|
by: Mike P |
last post by:
I know everything about reference counting and making sure you don't have
large objects lying around. I have also profiled my app with multiple tools.
I know about the fact GC collects memory but not necessary give it back to
the OS.
It seems that .NET win app will only return memory to the OS when the OS is
asking for it. But!!! When...
|
by: Evangelista Sami |
last post by:
hello all
i am implementing an application in which a large number of (char *)
is stored into a hash table structure.
As there may be collisions, each (char *) inserted into my hash table
is put into an array. here is the definition of my hash table :
typedef struct
{
short size;
|
by: Segfahlt |
last post by:
I have a fairly simple C# program that just needs to open up a fixed width
file, convert each record to tab delimited and append a field to the end of
it.
The input files are between 300M and 600M. I've tried every memory
conservation trick I know in my conversion program, and a bunch I picked up
from reading some of the MSDN C# blogs, but...
|
by: Larry |
last post by:
I am wondering if anyone has any thoughts on the following issues once
Ajax is incorporated into a page:
Now that we have this Ajax stuff, users have the potential to not leave
a page for a long time. My knowledge of browser memory handling is
limited, but I spoke with a Microsoft engineer who told me that IE has
a very naive mark and...
| |
by: Peteroid |
last post by:
I looked at the addresses in an 'array<>' during debug and noticed that the
addresses were contiguous. Is this guaranteed, or just something it does if
it can?
PS = VS C++.NET 2005 Express using clr:/pure syntax
|
by: Adrian |
last post by:
Hi
I have a JS program that runs localy (under IE6 only) on a PC but it has
a memory leak (probably the known MS one!)
What applications are there that I could use to look at the memory usage of
each object within my JS app to help locate my problem?
Thanks
|
by: Jim Land |
last post by:
Jack Slocum claims here
http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript-
memory-leaks/
that "almost every site you visit that uses JavaScript is leaking memory".
Anybody know anything about this?
Does *Javascript* leak memeory, or
does the *browser* leak memory?
|
by: kumarmdb2 |
last post by:
Hi guys,
For last few days we are getting out of private memory error. We have a
development environment. We tried to figure out the problem but we
believe that it might be related to the OS (I am new to Windows so not
sure). We are currently bouncing the instance to overcome this error. This
generally happen at the end of business day...
|
by: George2 |
last post by:
Hello everyone,
Should I delete memory pointed by pointer a if there is bad_alloc when
allocating memory in memory pointed by pointer b? I am not sure
whether there will be memory leak if I do not delete a.
try {
a = new int ;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |