Strange Puzzle - Invalid memory access of location
Posted
by
Rob Graeber
on Stack Overflow
See other posts from Stack Overflow
or by Rob Graeber
Published on 2012-11-19T15:15:45Z
Indexed on
2013/06/25
22:21 UTC
Read the original article
Hit count: 144
The error message I'm getting consistently is:
Invalid memory access of location 0x8 rip=0x10cf4ab28
What I'm doing is making a basic stock backtesting system, that is iterating huge arrays of stocks/historical data across various algorithms, using java + eclipse on the latest Mac Os X.
I tracked down the code that seems to be causing it. A method that is used to get the massive arrays of data and is called thousands of times. Nothing is retained so I don't think there is a memory leak. However there seems to be a set limit of around 7000 times I can iterate over it before I get the memory error.
The weird thing is that it works perfectly in debug mode. Does anyone know what debug mode does differently in Eclipse?
Giving the jvm more memory doesn't help, and it appears to work fine using -xint. And again it works perfectly in debug mode.
public static List<Stock> getStockArray(ExchangeType e){
List<Stock> stockArray = new ArrayList<Stock>();
if(e == ExchangeType.ALL){
stockArray.addAll(getStockArray(ExchangeType.NYSE));
stockArray.addAll(getStockArray(ExchangeType.NASDAQ));
}else if(e == ExchangeType.ETF){
stockArray.addAll(etfStockArray);
}else if(e == ExchangeType.NYSE){
stockArray.addAll(nyseStockArray);
}else if(e == ExchangeType.NASDAQ){
stockArray.addAll(nasdaqStockArray);
}
return stockArray;
}
A simple loop like this, iterated over 1000s of times, will cause the memory error. But not in debug mode.
for (Stock stock : StockDatabase.getStockArray(ExchangeType.ETF)) {
System.out.println(stock.symbol);
}
© Stack Overflow or respective owner