1. Memory leak?
- Posted by gwalters Feb 02, 2014
- 3917 views
I have been using Matt's odbc.ew v1.32 for many years w/o any problems. Today I have the need to create cursors recursively many times and what appears to be a memory leak has occurred. I'm just assuming that it is inside odbc.ew.
c:/AstroTrack/lib/odbc.ew:1079 in function allocHandleODBC() Your program has run out of memory. One moment please... htype = 3 parent = 2 id = 11 mset = <no value> ptr = 1807266080 hparent = 29746232 ... called from c:/AstroTrack/lib/odbc.ew:2182 in function createCursor() hconn = 2 sql = {115's',101'e',108'l',101'e',99'c',116't',32' ',42'*',32' ',102'f', 114'r',111'o',109'm',32' ',116't',121'y',99'c',111'o',50'2',48'0',48'0', 48'0',32' ',119'w',104'h',101'e',114'r',101'e',32' ',68'D',69'E',67'C',110'n', 117'u',109'm',101'e',114'r',105'i',99'c',32' ',62'>',61'=',32' ',54'6',49'1', 46'.',50'2',54'6',48'0',51'3',54'6',57'9',52'4',57'9',32' ',97'a',110'n', 100'd',32' ',68'D',69'E',67'C',110'n',117'u',109'm',101'e',114'r',105'i', 99'c',32' ',60'<',61'=',32' ',54'6',49'1',46'.',55'7',48'0',50'2',57'9', 50'2',57'9',51'3',49'1',32' ',97'a',110'n',100'd',32' ',82'R',65'A',110'n', 117'u',109'm',101'e',114'r',105'i',99'c',32' ',62'>',61'=',32' ',52'4',49'1', 46'.',48'0',56'8',52'4',53'5',50'2',49'1',52'4',56'8',32' ',97'a',110'n', 100'd',32' ',82'R',65'A',110'n',117'u',109'm',101'e',114'r',105'i',99'c', 32' ',60'<',61'=',32' ',52'4',49'1',46'.',53'5',50'2',55'7',48'0',56'8', 49'1',51'3'} hstmt = <no value> ptr = <no value> ok = <no value> stmt = <no value> cols = <no value> ... called from c:/AstroTrack/lib/dbfile.e:468 in function readNextDbC() t = 3
Does anyone have any idea how to fix this or find the bug? It would be very helpful. I can email you odbc.ew if you don't have it. Thanks
George
2. Re: Memory leak?
- Posted by mattlewis (admin) Feb 03, 2014
- 3849 views
I have been using Matt's odbc.ew v1.32 for many years w/o any problems. Today I have the need to create cursors recursively many times and what appears to be a memory leak has occurred. I'm just assuming that it is inside odbc.ew.
Does anyone have any idea how to fix this or find the bug? It would be very helpful. I can email you odbc.ew if you don't have it.
That's an old version. The latest that I posted to the archive is 1.34, though the source code itself says 1.36. It looks like 1.33 got several updates, including some memory leak fixes:
Fixed memory leaks in prepareSQL(), getColumnHeaders() and getData()
You can download the updated file here: https://sourceforge.net/p/eudbc/code/HEAD/tree/trunk/odbc.e
Matt
4. Re: Memory leak?
- Posted by gwalters Feb 04, 2014
- 3713 views
Matt,
I tried the newer verson of odbc.e and there was some improvement. Using the program with the same data the old version memory grew to 333Mb and the newer version grew to 304Mb. Got this by looking at task manager while the program ran (about 3 minutes). The memory required continues to grow until either the program terminates normally or runs out of memory.
The program is looking at a 2 degree square window of stars (Tycho satellite data) looking for colinear triplets. There are 112 stars in the window and it recursively creates a cursor of 111 stars 112 times searching for star triplets. The window cannot be larger because the program will give out of memory eventually.
So, there is some improvement but the basic problem is still present. Thanks for checking.
5. Re: Memory leak?
- Posted by Spock Feb 12, 2014
- 3716 views
The program is looking at a 2 degree square window of stars (Tycho satellite data) looking for colinear triplets. There are 112 stars in the window and it recursively creates a cursor of 111 stars 112 times searching for star triplets. The window cannot be larger because the program will give out of memory eventually.
So you're looking for star triplets by creating cursors, right? Could there be a better way to this analysis? I'm interested in what you're trying to achieve but I have no idea what it is..
Spock
6. Re: Memory leak?
- Posted by gwalters Feb 12, 2014
- 3682 views
The program is looking at a 2 degree square window of stars (Tycho satellite data) looking for colinear triplets. There are 112 stars in the window and it recursively creates a cursor of 111 stars 112 times searching for star triplets. The window cannot be larger because the program will give out of memory eventually.
So you're looking for star triplets by creating cursors, right? Could there be a better way to this analysis? I'm interested in what you're trying to achieve but I have no idea what it is..
Spock
7. Re: Memory leak?
- Posted by gwalters Feb 12, 2014
- 3589 views
The program is looking at a 2 degree square window of stars (Tycho satellite data) looking for colinear triplets. There are 112 stars in the window and it recursively creates a cursor of 111 stars 112 times searching for star triplets. The window cannot be larger because the program will give out of memory eventually.
So you're looking for star triplets by creating cursors, right? Could there be a better way to this analysis? I'm interested in what you're trying to achieve but I have no idea what it is..
Spock
There may be a better way to do this but I don't know of one. The data base has 2.5 million stars (took 4hrs to build) to search through. I'm not sure how to better explain what Im trying to do. I'm looking for star triplets that are in a straight line and are not off the straight line more then 1 arc sec. Now that you question the approach perhaps I should retreive the window of stars one time, put them in a table and search the table. Might be a better approach. Certainly avoid my memory problem. Send me your email address and I'll email you a paper I'm writing. gwalters at sc dot rr dot com.
8. Re: Memory leak?
- Posted by DerekParnell (admin) Feb 12, 2014
- 3580 views
There may be a better way to do this but I don't know of one.
If you are taking 112 stars at a time, there are only 227920 combinations to check. You could calculate (once) a list of all those combinations
{ { 1, 2, 3}, { 1, 2, 4}, { 1, 2, 5}, ... { 110, 111, 112} }
This would take about 4.5MB. Then grab the 'next' 112 stars, assigning each a number 1 to 112. Then loop through the list of combinations, checking each co-linear aspect of the group of three, and only save or report on ones that are within tolerance. You do not have to have all the stars in RAM at the same time, in fact you would only need three stars at a time. Just grab the details of the next 'three' off disk.
9. Re: Memory leak?
- Posted by jimcbrown (admin) Feb 12, 2014
- 3596 views
There may be a better way to do this but I don't know of one.
If you are taking 112 stars at a time, there are only 227920 combinations to check. You could calculate (once) a list of all those combinations
{ { 1, 2, 3}, { 1, 2, 4}, { 1, 2, 5}, ... { 110, 111, 112} }
This would take about 4.5MB. Then grab the 'next' 112 stars, assigning each a number 1 to 112. Then loop through the list of combinations, checking each co-linear aspect of the group of three, and only save or report on ones that are within tolerance. You do not have to have all the stars in RAM at the same time, in fact you would only need three stars at a time. Just grab the details of the next 'three' off disk.
Wow! Simple yet brilliant. As always, I'm impressed.
10. Re: Memory leak?
- Posted by gimlet Feb 13, 2014
- 3602 views
Really!
OK, so we make a list of 112 stars with their (x,y) coordinates. - how accurate?? We can have 111 stars as their first match, 110 stars as their second match = 112 * 111 * 110 = rather a lot more than 227,000 (where did that number come from?).
Second: If the distance between s1 and s2 is small (ie very small in relation to the distance from the origin) how accurate is any measurement going to be?
Third: how do you determine 3 points are collinear? That is given 3 points (x1,y1).. how will you determine they are collinear and not run into problems with dividing values by other values close to zero.
11. Re: Memory leak?
- Posted by jimcbrown (admin) Feb 13, 2014
- 3666 views
Really!
Yes, really.
OK, so we make a list of 112 stars with their (x,y) coordinates. - how accurate??
To 2.5 milliarcseconds, according to wikipedia: http://en.wikipedia.org/wiki/Tycho-2_Catalogue
We can have 111 stars as their first match, 110 stars as their second match = 112 * 111 * 110 = rather a lot more than 227,000 (where did that number come from?).
That's the formula for permutations, where order matters. We don't care about order here (e.g. 55,66,77 and 77,66,55 are the same star triplet to us), so we should be using the formula for combinations instead.
Permulations: 112!/(112-3)! = 112 * 111 * 110
Combinations: 112!/3!(112-3)! = 112 * 111 * 110 / 6 = 227,920
This is rather basic stuff: http://www.mathsisfun.com/combinatorics/combinations-permutations.html
Second: If the distance between s1 and s2 is small (ie very small in relation to the distance from the origin) how accurate is any measurement going to be?
Didn't you already ask this? Measurements are (supposedly) accurate to 2.5 milliarcseconds.
Third: how do you determine 3 points are collinear? That is given 3 points (x1,y1).. how will you determine they are collinear and not run into problems with dividing values by other values close to zero.
I imagine gwalters will use the same method that he used with edbc, as the determination of collinearity isn't affected by the change from edbc to Derek's method.
12. Re: Memory leak?
- Posted by gimlet Feb 13, 2014
- 3532 views
Jim
I choose 1 of 112 = first star I choose 1 of 111 = second star There are 110 stars to check for collinearity
112!/3! OK
Second:
Checking for collinearity is not fall over simple. See for example:
Lecture Notes on Geometric Robustness by JR Shewchuk
13. Re: Memory leak?
- Posted by jimcbrown (admin) Feb 13, 2014
- 3516 views
Jim
I choose 1 of 112 = first star I choose 1 of 111 = second star There are 110 stars to check for collinearity
112!/3! OK
You seriously mean to tell me that you believe that to check 110 stars for collinearity requires
32908447620351233725613672879332081390212978005829222966109382515817143161628635240149037392504629894432992889706308939712055819947730936968641796744046182400000000000000000000000000
permutations?! Not only is this number itself obviously ridicioulous, but it contradicts your own previous statement of 112 * 111 * 110.
I think at this point it is safe to declare that you have no idea what you are taking about.
Second:
Checking for collinearity is not fall over simple. See for example:
Lecture Notes on Geometric Robustness by JR Shewchuk
Agreed. I never claimed otherwise. Non sequitur. Please explain relevance of collinearity to usage of EDBC (what I originally posed).
14. Re: Memory leak?
- Posted by gimlet Feb 13, 2014
- 3515 views
Jim
The 112!/3! was a stupid error and certainly not = 112*111*110. I realised after I submitted that it was stupid.
I choose 3 stars in order. If I choose 1 2 3 then I will not choose 2 1 3 later and vice versa. But I could have as I did not specify a particular order (like the key of a combination lock).
So, I guess, Derek is wrong on that.
Second the point about accuracy. Quoting:
"I'm looking for star triplets that are in a straight line and are not off the straight line more then 1 arc sec."
That sounds to me like testing for collinearity with stars close together will have accuracy problems.
Third:
I would have thought Derek's approach was obvious but it has a problem in that a star may be collinear with a star or stars not in the 112 chosen. I have no idea how close together stars need to be to be considered "in a line". This is a complication.
15. Re: Memory leak?
- Posted by evanmars Feb 13, 2014
- 3493 views
Just a quick, not totally OT question. I definitely don't know what I'm talking about.
Why is it difficult to check for linearity? If you have points A, B, and C, why can't you use the vector equation [x,y] = A + (B - A)t?
Or is it an issue of rounding off errors?
16. Re: Memory leak?
- Posted by jimcbrown (admin) Feb 13, 2014
- 3508 views
Jim
The 112!/3! was a stupid error and certainly not = 112*111*110. I realised after I submitted that it was stupid.
Okay.
I choose 3 stars in order. If I choose 1 2 3 then I will not choose 2 1 3 later and vice versa.
Ok, so it's a combination without repetition in that case.
But I could have as I did not specify a particular order (like the key of a combination lock).
If you did so, then you'd change it into a permutation. Why would gwalters want to do that though? He's better off doing a combination if he can get away with it (as that means fewer overall computations).
So, I guess, Derek is wrong on that.
I disagree. If we both agree that it's a case of using combination without repetition, then Derek's original number is correct.
If gwalters is doing a permutation instead (either because he has to, or perhaps because gwalters enjoys the music of gnashing hard disks and the flash of blinkenlights), then Derek's number is wrong.
Second the point about accuracy. Quoting:
"I'm looking for star triplets that are in a straight line and are not off the straight line more then 1 arc sec."
That sounds to me like testing for collinearity with stars close together will have accuracy problems.
The data on star position is supposedly accurate to 2.5 milliarcseconds. So the margin of error is 400 times smaller than what gwalters is looking for. There's always room for errors in measurement and other forms of accuracy, but it seems that gwalters has plently of wiggle room.
Third:
I would have thought Derek's approach was obvious but it has a problem in that a star may be collinear with a star or stars not in the 112 chosen. I have no idea how close together stars need to be to be considered "in a line". This is a complication.
I agreed that this looks like a potential complication, but it's also one present in the original EDBC using program.
17. Re: Memory leak?
- Posted by mattlewis (admin) Feb 13, 2014
- 3534 views
Jim
The 112!/3! was a stupid error and certainly not = 112*111*110. I realised after I submitted that it was stupid.
I choose 3 stars in order. If I choose 1 2 3 then I will not choose 2 1 3 later and vice versa. But I could have as I did not specify a particular order (like the key of a combination lock).
So, I guess, Derek is wrong on that.
No, you still haven't processed what Derek and Jim said about this. Here's a combinatorics calculator. As it specifies, the formula for unique combinations is:
n!/((n-r)! * r!)
...where n is the number of items total, taken r at a time. You say you're choosing them in order, which means that you'd choose both (1,2,3) and (2,1,3) using standard mathematical language. Derek was correct about the number of 3-tuple combinations of 112 stars when order isn't important.
Matt
18. Re: Memory leak?
- Posted by DerekParnell (admin) Feb 13, 2014
- 3464 views
Jim
The 112!/3! was a stupid error and certainly not = 112*111*110. I realised after I submitted that it was stupid.
I choose 3 stars in order. If I choose 1 2 3 then I will not choose 2 1 3 later and vice versa. But I could have as I did not specify a particular order (like the key of a combination lock).
So, I guess, Derek is wrong on that.
Huh? I assumed that checking stars 1, 2, 3 would be identical to checking stars 2, 1, 3. Am I wrong there?
Third:
I would have thought Derek's approach was obvious but it has a problem in that a star may be collinear with a star or stars not in the 112 chosen.
Yep ... that would be an issue. The '112' might have to be flexible. One could sort all the stars such that they are grouped into approximate or near co-linear and then apply a 'sliding' window over them. Not a trivial exercise though.
19. Re: Memory leak?
- Posted by gwalters Feb 14, 2014
- 3415 views
this is how I calculated the distance the central star is from the outer 2 stars.
---------------- Calculate Distance star 3 is from line joining star1 and star2 --------------- procedure calc(sequence star1, sequence star2, sequence star3) atom phi, tanPhi, sinPhi -- y = DEC direction -- x = RA directioin tanPhi = (star2[DECnumeric] - star1[DECnumeric])/(star2[RAnumeric] - star1[RAnumeric]) if tanPhi = 0 then -- its perfectly horizontal distance = star3[DECnumeric]- star1Rec[DECnumeric] else phi = arctan(tanPhi) sinPhi = sin(phi) distance = ((star3[DECnumeric]- star1Rec[DECnumeric]) / tanPhi - (star3[RAnumeric]- star1Rec[RAnumeric])) * sinPhi distance = distance * 3600 -- convert to seconds end if end procedure
Draw a pic of the situation and use y=mx+b plus a little trig. Works fine.
20. Re: Memory leak?
- Posted by gwalters Feb 14, 2014
- 3411 views
As far as the accuracy of tyco-2000. The above quoted 2.5 mili-arc-seconds/year is for the proper motion of a star, it's motion across the sky relative to the fixed background of stars. The positional accuracy is 60 mas. All this is per tyco literature.
What I have found so far, looking at 60min windows, is that 10-30 persent of the stars ar colinear to less thatn 1 arcsec at least for the areas I've looked at. Program blows up if I look at a window larger or there are too may stars in the window. I now have to fugure out why. That's the real problem.
Thanks for all your interest and ideas on how to improve the program. I obviously need to improve the algorithm.
21. Re: Memory leak?
- Posted by Spock Feb 14, 2014
- 3359 views
As far as the accuracy of tyco-2000. The above quoted 2.5 mili-arc-seconds/year is for the proper motion of a star, it's motion across the sky relative to the fixed background of stars. The positional accuracy is 60 mas. All this is per tyco literature.
What I have found so far, looking at 60min windows, is that 10-30 persent of the stars ar colinear to less thatn 1 arcsec at least for the areas I've looked at. Program blows up if I look at a window larger or there are too may stars in the window. I now have to fugure out why. That's the real problem.
Thanks for all your interest and ideas on how to improve the program. I obviously need to improve the algorithm.
I would approach this as a "bitmap" problem. Let the image be, say 10000 x 10000. Plot the (center of) the stars on the image (just like setting a pixel but using the star index instead of a color) and then test a window of area about each star to pull out the adjacent stars to check for colinearity [the original star can be the center of the triplet]. The image would be plotted in RAM and I would be using ASM for the window extraction.
Also, the stars extracted from the would have the angles calculated between them and the center star. Those angles could them be sorted so your colinearity searching function should be scorchingly fast as you only need to test each of the stars in the window against the small group that corresponds to 180 degrees away.
Spock
PS: I can help with the ASM code, if you want.
22. Re: Memory leak?
- Posted by gimlet Feb 15, 2014
- 3324 views
this is how I calculated the distance the central star is from the outer 2 stars.
The way you say this seems to imply the stars are well separated.
If they are not the procedure could be unreliable.
Consider A is distant from B but C is close.
You would (in this case) measure the distance A is from the line BC.
Another way your code may be unreliable is that you use tan, sin and division with numbers which can be close to or equal to zero. Double precision is very accurate but it looks as though some the numbers you could encounter could differ by a factor as large as 10^12.
E.G. line
tanPhi = (star2[DECnumeric] - star1[DECnumeric])/(star2[RAnumeric] - star1[RAnumeric])
What if star2[RAnumeric] = star1[RAnumeric]? or
distance = ((star3[DECnumeric]- star1Rec[DECnumeric]) / tanPhi - (star3[RAnumeric]- star1Rec[RAnumeric])) * sinPhi
Both tanPhi and sinPhi can approach zero and tanPhi can approach +-inf.
Perhaps you could do something this:
Move the origin to the central star's position. (get distances relative to B) Determine the closer of the outer stars (A). Determine the the angle BAC etc.,
The book Lecture Notes on Geometric Robustness by JR Shewchuk is available free on the web. And it seems rather good.
23. Re: Memory leak?
- Posted by gimlet Feb 15, 2014
- 3354 views
Derek, Matt, Jim
Re selection.
I wrote that in the middle of the night. Yes it was wrong and rather silly. I must have been more tired than I thought. I didn't respond earlier because I had other things to do.
However I will say this.
I suspected (and this was borne out) that people were thinking that collinearity is associative. And that meant that checking C was appropriately close to the line through AB was a sufficient condition.
You can also run a line which only passes through the central star which would satisfy linearity.
You can run a line through two stars which apparently demonstrates the linearity of the 3 when the third star C is off at a sixty degree angle.
You can run a line which passes through none of the 3 stars which satisfies linearity.
All told the problem is rather more difficult than it seems.
24. OT: Colinearity of Stars in Our Galaxy
- Posted by SDPringle Feb 15, 2014
- 3311 views
As far as the accuracy of tyco-2000. The above quoted 2.5 mili-arc-seconds/year is for the proper motion of a star, it's motion across the sky relative to the fixed background of stars. The positional accuracy is 60 mas. All this is per tyco literature.
What I have found so far, looking at 60min windows, is that 10-30 persent of the stars ar colinear to less thatn 1 arcsec at least for the areas I've looked at. Program blows up if I look at a window larger or there are too may stars in the window. I now have to fugure out why. That's the real problem.
Thanks for all your interest and ideas on how to improve the program. I obviously need to improve the algorithm.
G. Walters,
Somethings that mean seem impossibly unlikely may be actually probable. First thing I would ask is what is the density of stars in the data you are looking at. How many stars are in your 60min by 60min Windows? Perhaps it is just a statistical property of having that many dots in a 3600x3600 grid, generally means that 10-30 % are co-linear. The fact that the galaxy is in a flat shape like a plate makes the stars in space unlike random dots in a grid. You are looking at the plate from its edge, after all.
Play pool, often I cannot find the cue ball, another and a hole are co-linear at the end of the game when there are fewer balls. It is much easier at the beginning of the game. The question here is what is the probability of getting up to 30% of the points colinear in such a grid given this bias of the galaxy is deformed into a plate and our perspective?
S D Pringle
25. Re: Memory leak?
- Posted by gwalters Feb 15, 2014
- 3340 views
What if star2[RAnumeric] = star1[RAnumeric]? or
The book Lecture Notes on Geometric Robustness by JR Shewchuk is available free on the web. And it seems rather good.
Your are correct. The stars are quite separated in the regions I've looked. I did run into a case where star1 and 2 are perfectly horizontal but not vertical, so the routine did not consider that.
26. Re: OT: Colinearity of Stars in Our Galaxy
- Posted by gwalters Feb 15, 2014
- 3325 views
Somethings that mean seem impossibly unlikely may be actually probable. First thing I would ask is what is the density of stars in the data you are looking at. How many stars are in your 60min by 60min Windows? Perhaps it is just a statistical property of having that many dots in a 3600x3600 grid, generally means that 10-30 % are co-linear. The fact that the galaxy is in a flat shape like a plate makes the stars in space unlike random dots in a grid. You are looking at the plate from its edge, after all.
Play pool, often I cannot find the cue ball, another and a hole are co-linear at the end of the game when there are fewer balls. It is much easier at the beginning of the game. The question here is what is the probability of getting up to 30% of the points colinear in such a grid given this bias of the galaxy is deformed into a plate and our perspective?
[Edit: Fixed the quote box above here: S D Pringle]
You have got to the heart of the problem. At first I thought that the 2 outer stars were orbiting each other around the center of mass and the central star was resting at a neutral point between. The results seen, looking at the proper motion, killed that idea. So I am left with the problem of how/why are they aligned so closely. The regions I've looked at are not through the milky way, but mostly perpendicular. (i.e. 5,0,0 RA and 5,0,0 DEC)
27. Re: Memory leak?
- Posted by gwalters Feb 15, 2014
- 3323 views
I would approach this as a "bitmap" problem. Let the image be, say 10000 x 10000. Plot the (center of) the stars on the image (just like setting a pixel but using the star index instead of a color) and then test a window of area about each star to pull out the adjacent stars to check for colinearity [the original star can be the center of the triplet]. The image would be plotted in RAM and I would be using ASM for the window extraction.
PS: I can help with the ASM code, if you want.
I thank you for the offer. I think I have enought information/confusion on results now to try and figure out why they are colinear. I'm meeting monday with the astronomy dept at USC later to discuss what I've run into.
Thanks George
28. Re: OT: Colinearity of Stars in Our Galaxy
- Posted by gimlet Feb 15, 2014
- 3288 views
At first I thought that the 2 outer stars were orbiting each other around the center of mass and the central star was resting at a neutral point between. The results seen, looking at the proper motion, killed that idea. So I am left with the problem of how/why are they aligned so closely. The regions I've looked at are not through the milky way, but mostly perpendicular. (i.e. 5,0,0 RA and 5,0,0 DEC)
Perhaps what you are seeing is a star stream. I would have thought that the stars were mostly independent (you say the triples are well separated). Do they have similar alignments? One would expect galaxy stars would be (more or less) randomly aligned. A star stream on the other hand would not be randomly aligned (common direction).
The other day I was at the Powerhouse and one of the exhibits was iron filings in a magnetic field. The pictures you usually see are nicely aligned to the lines of force - great visualisations. What I saw was something only a bit like that: a large clump of filings which tended to stick together not very well aligned in the small but in the large obviously constrained by the field.