I try to populate CvSeq as input for cvDrawContours, but the JVM almost reliably crashes with EXCEPTION_ACCESS_VIOLATION at various places, most often at
[msvcr100.dll+0x3c19b] memcpy+0x20bor[opencv_core243.dll+0x61793] cvSeqPush+0x133
public static void main(String[] args) { CvMemStorage memStorage = CvMemStorage.create(); CvSeq seq = cvCreateSeq(0, Loader.sizeof(CvSeq.class), Loader.sizeof(CvPoint.class), memStorage); for (int j=0; j<1000000; j++) { CvPoint cvPoint = cvPoint(j, j+1); System.out.println(j); cvSeqPush(seq, cvPoint); } }In my configuration it fails most often after about 50000 iterations (with -Xmx64m -Xms64m, Oracle JVM 1.6.0_31 64 bit on Windows), but sometimes at other count or not at all. There is apparently some allocation/deallocation error.
As I found out, it fails after the heap is full and GC needs to be run. If I explicitly call
System.gc()after 20000 iterations, it fails insidecvSeqPushright after the GC (or 1-2 iterations later, probably because pointer from deallocated space happens to point to correct address). Or if I decrease or increase heap size, it fails sooner or later. Probably something in use is automagically deallocated.Is someone able to decipher the
0x61793address from the opencv_core243.dll? This may give a clue.Thank you in advance,
Viliam