Tue Jan 19, 2016 1:43 pm
Further to the above I still have a problem where the graphics window gets corrupted after a long time, about 45 mins of continuous looping, which has only come to light this weekend due to the number and frequency of prompts being written to the screen.
I am using Raspberry Pi 2, not overclocked, with latest updates of the OS, firmware and openvg-master (as of 2 days ago.)
I use 256MB for the GPU in the memory split setting.
I read an ADC, calculate values and display the results in a graphics window in different sized and colour fonts. I also display the ADC as an oscilloscope display and loop continuously until a key is pressed. It will happily run for about 45mins then several things may happen:
1. The background is normally red and the text (28 point) is white. After about 45 mins, one or more triangular shapes will draw themselves in white on the screen and the looping will gradually slow down. I can still exit on a key press and rerun the program again OK until it happens once more after some time.
or
2. The whole system will stop looping (or become so slow as to give the appearance it has stopped) and the only way to get out is to force a break by pressing the Pause/break key.
However, if 2) has happened, when I now try to rerun the program it will not run as in 1) - instead it will hang at the point when calling the init(..) routine (which is in shapes.h). To check, I put a printf() prompt before and after the call to init(..) and do not get the after prompt so it appears that it has not returned from init(..).
The program will now not rerun at all.
However, if I reboot the RPI and rerun the program (without any changes at all) all is fine and it will once more run again for about 45 mins until 1) or 2) happens.
It is as though memory is being created, hogged and not released correctly (and a glyph gets drawn across the screen as in 1). I am not creating or releasing memory blocks in my code - all memory is fixed global arrays.
For info: I am using an additional font (digit7) and use it as described by pearyn in another post. I write 3 digits in that font in another window and use the standard built in fonts (Serif, etc) to display the looping ADC results
Can anyone suggest how to track this problem down and how to monitor memory usage to see what is being used and what is not released.
I don't have another problem with the openvg that I know of, but this could be because in my other projects I only write a few graphic text prompts every so often, whereas this project is continously looping and updating the graphics text prompts every 100mS and so if there is an any memory problem it would be seen quicker.
Update: when I look at memory usage from the command line using:
$ sudo vcdbg reloc stats
1. Before running the program:
Relocatable heap version 4 found at 0x2f000000
total space allocated is 236M, with 236M relocatable, 0 legacy and 0 offline
0 legacy blocks of size 2359296
small_allocs : 23
allocs : 13
alloc_fails : 0
legacy_block_fails : 0
compactions : 0
discard_compactions : 0
aggressive_compactions : 0
aggressive_compaction_waits : 0
aggressive_compaction_timeouts: 0
locks : 0
small_locks : 0
free list at 0x3d897920
233M free memory in 1 free block(s)
largest free block is 233M bytes
2. After running for awhile and seeing the looping slowing down, I exit from the program and this is typical of what I get:
Relocatable heap version 4 found at 0x2f000000
total space allocated is 236M, with 234M relocatable, 0 legacy and 2.3M offline
0 legacy blocks of size 2359296
small_allocs : 2019
allocs : 5827729
alloc_fails : 0
legacy_block_fails : 0
compactions : 0
discard_compactions : 0
aggressive_compactions : 0
aggressive_compaction_waits : 0
aggressive_compaction_timeouts: 0
locks : 0
small_locks : 0
free list at 0x3d796860
invalid space 0x1465210709 in free list at 0x3c1c8b00
1.1M free memory in 9 free block(s)
largest free block is 438K bytes
I am not sure what this means, but it seems as though the largest free block has dropped down from 233MB to 438KB, with 5827729 allocs.
As mentioned, when I then try to re-run the program, it cannot get passed the graphics init(...). Is there any method in software to forceably clear out the memory. The only way I know is to reboot the Raspberry Pi! Any pointers would be gratefully received.
Thanks for looking
Steve