Forums

General Betting

There is currently 1 person viewing this thread.
Feck N. Eejit
21 Nov 11 16:12
Joined:
Date Joined: 10 Jan 02
| Topic/replies: 8,841 | Blogger: Feck N. Eejit's blog
I was using the LoadFromFile method for a TStringList in C++ builder to load the betfair data .csv files. It could handle files of size 144 MB but when it reached 155 MB I was getting "Out of memory" exceptions. I couldn't be bothered re-coding so I upgraded the memory from 2 GB to 4 GB (Vista) but still get the "Out of memory" exception. I know Windows can't use the whole 4 GB but surely the extra GB or so should be more than enough. Any programmers cast any light on this for me?

Post your reply

Text Format: Table: Smilies:
Forum does not support HTML
Insert Photo
Cancel
Page 1 of 2  •  Previous 1 | 2 | Next
sort by:
Show
per page
Replies: 58
By:
bf_fananatic
When: 21 Nov 11 17:01
I hit a similar problem with excel 2003 as my files reached 150 mb size but in my case no message just the computer hanging up.

I tried expanding the memory from 2gb to 3gb but with the same negative result, I then found there was a limit to excel 2003 memory usage as its capped at 1gb so no matter how much memory you have available excel 2003 can only use 1gb.

Your problem concerns c++builder of which I am not familiar with but probably there is a application memory limitation
that caps the size of certain memory intensive operations, my advice would be to load the csv flies into another application and breakdown the file into more workable sizes both enabling the desired operation and speeding up the pc generally, after the resizing of the files you should be able to load with no further problems.
By:
Feck N. Eejit
When: 21 Nov 11 17:11
Thanks bff. Having just done a bit of googling I think you may be correct. Splitting the files would be more hassle than re-coding though. Cry
By:
Ghetto Joe
When: 21 Nov 11 17:12
It's more likely there's a limit to the amount of strings it can import/hold rather than the actual overall size of those strings.

I'm not clued up with C++ but you'll probably find they're are setting somewhere within the program where you can amend/increase the amounts it can handle I think it may be a file called LIMITS.H that'll show any limitations. Plus you may also be limited by the processor's own limits i.e. a 64 bit newer PC will have a lot higher limits than a 32Bit
By:
Feck N. Eejit
When: 21 Nov 11 17:14
What a wasted day. Upgrading the memory involved removing the keyboard (not easy) and it turned out my memory consisted of 1 x 2 GB and not the 2 x 1 GB I thought I had. This means I've also got to return one of the 2 x 2 GB memory modules.
By:
Feck N. Eejit
When: 21 Nov 11 17:19
http://www.festra.com/wwwboard/messages/12989.html

Thanks Joe. The above link would suggest otherwise though. I initially got the same "Out Of Memory" exception for the 144 MB file but was able to process that one after removing a few programmes from memory which would suggest it's not a TStringList problem.
By:
Ghetto Joe
When: 21 Nov 11 17:27
I don't think there are any memory contraints with TStringList other than available memory Feck, it'll most likely be down to the number of strings that'll be limited either within some settings in the program or the processors limitations . Do you know how many records the 144mb and 155Mb held?
By:
bf_fananatic
When: 21 Nov 11 17:27
Interestingly I have tried importing the csv historic data files into excel and I get some of the file chopped off due to memory limitation, the files themselves are far to big for average application management and they do not cover all the markets for all sports but this falls inline with betfairs falling short policy for fully maintaining there services to customers as I assume that betfair fails to understand that most exchange users are more sophisticated than the average joe throwing his money into a bookmakers shop or website even though betfair now relies on the same inteligent professional punters that liquidate markets for there profits in the form of premium charging.Mischief
By:
Feck N. Eejit
When: 21 Nov 11 17:39
I don't know the number of records Joe. I could find out, but not without coding.
By:
bf_fananatic
When: 21 Nov 11 17:50
historic data we can use (still waiting) betfair starting price result for all sports (still waiting) more contact between the towers and the customers over betfairs direction and policy comitment(still waiting)
best betting exchange in the world, ( got that) oh well 1 out of 4 aint bad.
By:
catflappo
When: 21 Nov 11 17:57
You think that a message issued by Microsoft saying "Out of Memory" means you are out of memory?
By:
bf_fananatic
When: 21 Nov 11 18:02
I like the open source approach to application development and upkeep and perhaps considering the immense work load betfair is under more members should help each other to implement matters concerning information management, afterall exchanges are the only betting sites that allow members to openly culture an edge.
By:
Beat The OverRound
When: 21 Nov 11 19:07
Feck, couple of things you can try.

CTRL ALT DEL start windows task manager.
Right click your Process and select Priority realtime befaore executing the program.

Also your virtual memory could be changed to double your physical ram instead of windows managed size.
Both these fixes in conjunction should fix the problem unless it is an actual limitation of the program.

cheers.
By:
Feck N. Eejit
When: 21 Nov 11 20:06
Thanks BTO. Neither helped unfortunately.
By:
bf_fananatic
When: 21 Nov 11 20:14
I am pretty confident the answer to your particular problem will be to load historic data in csv format into some app that will then allow you to seperate the big file into smaller files for better manipulation, someone will have the answer soonHappy
By:
Feck N. Eejit
When: 21 Nov 11 20:40
I could write code to do that bff. Wish I'd just done it instead of going through all this memory hassle. Cry
By:
Ghetto Joe
When: 21 Nov 11 22:31
I've used this csv splitter before feck, very simple and works fine. Might be worth using until you either find some fix or end up having to rewrite some of your code

http://www.fxfisherman.com/downloads/csv-splitter-1.1.zip
By:
dogform
When: 21 Nov 11 23:23
bff,

It is not memory causing the issue you are getting re the csv file being chopped off when loading into excel. It is a limitation of excel 2003 where a worksheet can only store 65,536 rows. Excel 2007 onwards can store 1 million rows. Try importing the csv files into an access/MySQL/SQL Server database and they load OK without truncation. One point to note is that if you are loading a lot of csv files into an access database there is an upper file size limit of 2gb for the access.mdb file.
By:
brendanuk1
When: 22 Nov 11 00:11
might be worth a shot

http://www.delphibasics.co.uk/Article.asp?Name=Memory

// Free up the string list memory
   FreeAndNil(fileData);

when you dont need it anymore, incase some unused are hanging around
By:
Feck N. Eejit
When: 22 Nov 11 11:34
Thanks Joe, I'll take a look but I suspect I'd be better just writing a bit of code and getting it over and done with.

Brendan, thanks but it's not that. The file that's currently causing the problem is the first one to be assigned to the TStringList.
By:
bf_fananatic
When: 22 Nov 11 12:51
thanks dogform for the tip will look into sql/access as soon as I finish with my current vb/api project, just wish I had the free time I had when I didnt have a family to look after , not complaining though.
By:
Chilly the Dog
When: 22 Nov 11 14:46
This is highlighting a fundamental flaw in your application's design. What if you wanted to decode and (presumably store in a DB) a 10gig file?

What you want is to do batching during the read. Read 10,000 lines at a time and process them. Since the file is a CSV and each line is independent you don't even care where you do the batching.

If you then convert the parsed CSV to a more efficient memory structure (from strings to ints and timestamps) you then save a huge amount of memory again.

Eg:

A CSV line consists of (this in no way reflects the data you're looking at but it serves the purpose):
2011-11-22T14:33:10.311+0010,2011-11-22T14:35:25.871+0010,5242341,1342524511,B,1.01,546.22,1234.12

This is
-two timestamps at millisecond accuracy (8 bytes as a 64 bit integer or 28 bytes as a string: 3.5x saving)
-two large numbers (8 bytes each as a 64 bit integer or 17 bytes as strings: 1.06x saving)
-one character B - 1 byte - no real saving to be had here.
-three decimal numbers  4 bytes each stored as a 32bt floating point number or 13 bytes as strings: 1.6x saving

Overall you can store it in 41 bytes as native data types , or 87 bytes for the strings, an overall saving of over 50%.

You also speed your program up because you dont need to faff about parsing strings all day, you parse each string once then access it natively in it's binary representation.
By:
Feck N. Eejit
When: 22 Nov 11 15:00
I agree it was lazy coding Chilly but I haven't found a cure yet for the laziness. Cry
By:
Chilly the Dog
When: 22 Nov 11 15:20
I'm not saying lazy, I'm just saying not designed with scalability in mind. As a professional coder I dream this stuff (whether I like it or not..) but I fully appreciate there are people (perhaps you are one) who dont have comp sci degrees and years of experience who just want to get stuff done.
By:
Chilly the Dog
When: 22 Nov 11 15:20
I'm not saying lazy, I'm just saying not designed with scalability in mind. As a professional coder I dream this stuff (whether I like it or not..) but I fully appreciate there are people (perhaps you are one) who dont have comp sci degrees and years of experience who just want to get stuff done.
By:
Feck N. Eejit
When: 22 Nov 11 15:55
I'm sure I could've done it gooder Silly Chilly but couldn't be @rsed. The thought of having to look up c++ file access functions was enough to put me off.
By:
brendanuk1
When: 22 Nov 11 16:10
get couple of "interns" preferably with big tits and get them to type it in Cool you know it makes sense
By:
bf_fananatic
When: 22 Nov 11 16:29
A fact of life regarding current pc capabilities is that once you start accumulating very large databases of info in what ever form it becomes impossible eventually to work on it with the data present in memory(ram) so the need to load and unload data becomes the mode of operation, this activity in itself then lends to using a programming language to circulate the databases as many database and spreadsheet programs don't cater for this ability.

This increase in I.T. knowledge needed when venturing into information studies is unavoidable unless limiting the
accuracy of data observation via limiting database sizes, it all boils down to accessing how much time and effort you have or can place into such research, as we all have come to learn in this sphere.
By:
Escapee
When: 22 Nov 11 16:45
Are you specifying the 'BlockSize' in the TStringList Constructor ?

If not then there's a possibility that its starting with a small block size ( memory allocation ) and its getting bigger for each allocation ( it could be doubling or some other exponential formula ). Thus causing it to request
a excessively large memory allocation.


If its not got anything to do with initial BlockSize then I would look at 'Handles'. Its likely that the inerds of TStringList use handles to pass
arround pointers to the string value. And there is a limit to how many handles
a process can create (and indeed a system wide limit as well).

If you run out of available slots for Handles then you will get an out of memory message, even if its not out of memory. ( same is true for various resources like gdi, timers etc )

Its a long time since I looked at this issue, and it was on an old windows ME pc.
I think it is possible to increase the number of system wide handle slots available. using some utility in control panel ( can't remember how to do this off the top of my head )
By:
Feck N. Eejit
When: 22 Nov 11 16:54
Thanks Escapee but I can't find any BlockSize property associated with TStringList.
By:
Escapee
When: 22 Nov 11 17:01
what version of Visual Studio are you using ? ( or is it Borland C ? )

I didn't find a lot of documentation on TStringList, most of it said "use the
documentation for TObjList"

to set the Block size try this:

int nBlockSize = 1024000;
TStringList myList = new TStringList( nBlockSize )

my documentation doesn't specify if Blocksize is actual memory allocation or number of list entries. So you might have to factor it up or down abit to get an optimal size for your app.
By:
bf_fananatic
When: 22 Nov 11 17:12
http://stackoverflow.com/questions/2680635/tstringlist-dynamic-array-or-linked-list-in-delphi

try the above link for your problem is almost identical and the solutions are there posted by programmers in the field.
By:
Feck N. Eejit
When: 22 Nov 11 17:22
It's embarcadero rad studio Escapee (used to be borland). I tried it but no matter how big I made the constructor parameter I still got the out of memory message at LoadFromFile. Cry
By:
bf_fananatic
When: 22 Nov 11 17:23
stackoverflow is quite a good programers forum as they cover most programming langs/platforms and give free advive from begineers to pros.
By:
bf_fananatic
When: 22 Nov 11 17:24
excuse the typos
By:
Feck N. Eejit
When: 22 Nov 11 17:37
bff, thanks. I read that all the way through but I don't really see it helps.
By:
Chilly the Dog
When: 22 Nov 11 17:39
I'd bite the bullet and do the parsing manually. Reading lines from a file in C++ is really easy: get onto google for fully working examples.
By:
Feck N. Eejit
When: 22 Nov 11 17:40
I tried the following

for (int i=1; ; i++) StringList->Add(i);

It went out of memory when StringList->Count was 38,873,827

for (int i=1; ; i++) StringList->Add(i*i);

went out of memory when StringList->Count was 31,099,062

which suggests it's not a max number of strings problem.
By:
bf_fananatic
When: 22 Nov 11 17:43
there was a reference to the limiatation of T-string memory sizes over 150mb plus and better aproachs for huge file sizes, just thought it might help.
By:
Feck N. Eejit
When: 22 Nov 11 17:44
I think you're right Chilly Cry
Page 1 of 2  •  Previous 1 | 2 | Next
sort by:
Show
per page

Post your reply

Text Format: Table: Smilies:
Forum does not support HTML
Insert Photo
Cancel
‹ back to topics
www.betfair.com