 tstanley
		
			tstanley
		
		
		
		
		
		
		
		
	
			11-14-2011 03:48 PM
Hi,
Can anyone shed some light on why user interface library functions may return a -12 UIEOutOfMemory error? I'm seeing this occasionally when I'm trying to use SetCtrlAttribute to set the ATTR_HEIGHT and ATTR_WIDTH of a canvas control. It doesn't happen often, but it's enough to be noticable. I thought it might be because I had a largish (640x480 resolution) bitmap drawn on the canvas, but it still happens when I call CanvasClear() first, though perhaps slightly less often. Any ideas? I'm using CVI 2010 SP1 on Windows XP. Thanks.
11-15-2011 08:39 AM
When you're dealing with a canvas control (unlike what happens with a picture control) the objects that you draw onto the canvas don't continue using memory after you draw them. Therefore, once you draw your large bitmap onto the canvas, the amount of memory used by your GUI will remain the same as if you had left the canvas blank. Clearing the canvas also has no effect on memory usage.
The canvas maintains an offscreen bitmap which contains everything that you've drawn onto the canvas (depending on your draw policy). When you resize your canvas, this offscreen bitmap must to be resized to match the new size of the canvas. This is the most likely step that's causing the out of memory error for you. It's pretty unusual for this to happen, unless you're making the canvas very large. But I've seen it happen before if your system's memory is very fragmented and a new large contiguous bitmap simply cannot be allocated.
Is it fairly easy for you to reproduce this error? If so, to confirm that this is what's happening, can you please run the C:\Program Files\National Instruments\CVI2010\bin\ConfigCVILogging.exe utility and generate a log file for your application? (You'll have to select the "Release" Runtime Engine as the item that you want to log, and you should probably select all message types). The log file will probably not be very meaningful to you, but you can attach it here, and I can take a look at it to see if anything unusual jumps out at me.
Luis
11-17-2011 09:26 AM
Hi LuisG,
Thanks for the reply. It's kind of sporatic to reproduce, but I was able to capture it with the Logging (logging to the Windows App Log). In this case the UIEOutOfMemory error actually occured on the CanvasClear command that I added immediately proceeding the SetCtrlAttribute() commands to resize the canvas. I've attached the log to this message. I know you had mentioned that the CanvasClear() probably wouldn't make a difference but I hadn't taken it out yet. Hopefully it contains the information you would need to look into it. I don't have enough data yet, but I think it might have to do with having dual monitors on the PC (as in, it doesn't seem to happen when I have only one monitor hooked up to the PC) but I haven't observed it enough to be sure. Thanks for looking into it.
11-17-2011 12:15 PM
Thanks for the log. It does correspond to an error in the CanvasClear function, but it seems to be suggesting that the canvas' storage bitmap was corrupted at the time that the CanvasClear function was called. I don't really how that could happen, since you don't resize the canvas until after you've called CanvasClear. I take it there was nothing else in the original, text-based log file, besides these 8 lines?
Since this is hard to reproduce, it might take us a few iterations of sending logs back and forth before we can get to the bottom of this. I'll send you a private message with my email address, and we should probably move this discussion to email. Once it wraps up, we can post the conclusion back here, in the forum.
Luis
11-17-2011 12:22 PM
Hi LuisG,
I cropped it down to the log entries that happened right when the problem occured. I'll see if I can get it to happen again this time I'll keep the proceeding log entries (there are quite a few).
Thanks.
 mjl
		
			mjl
		
		
		
		
		
		
		
		
	
			01-11-2013 12:17 PM
Hi, I have the same problem happening,. 2010 SP1, on an XP machine 1 GB of RAM. The final version runs on a Windows 7 machine w/ 4GB. The original application controls 6 cameras and displays them on the screen. I wrote the app over a year ago and it worked fine originally. The customer was complaining that it would ocasionally stop displaying the images. I had to revisit the program. I have no issues displaying small jpg's, but I need to display large jpegs 12 megapixel, 5MB. I wrote the small application included below to just load a jpg. Is there a way to change the UI memory allocation?
I have attached the dump log and here is the code.
#include <utility.h>
#include <formatio.h>
#include <cvirte.h>        
#include <userint.h>
#include "Test.h"
static int panelHandle;
int main (int argc, char *argv[])
{
    if (InitCVIRTE (0, argv, 0) == 0)
        return -1;    /* out of memory */
    if ((panelHandle = LoadPanel (0, "Test.uir", PNL_MAIN)) < 0)
        return -1;
    DisplayPanel (panelHandle);
    RunUserInterface ();
    DiscardPanel (panelHandle);
    return 0;
}
int CVICALLBACK cbkDir (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{ // CVICALLBACK cbkDir
    static char    szDir[MAX_PATHNAME_LEN];
    static char    szFile[MAX_PATHNAME_LEN];
    static char szDrive[MAX_PATHNAME_LEN];
    static char szTemp[MAX_PATHNAME_LEN];
    int    iRet;
    switch (event)
    { // event
        case EVENT_COMMIT:
            GetCtrlVal(panel, PNL_MAIN_TXT_IMG_FILE, szTemp);
            if (FileSelectPopup(szTemp, szFile, "*.jpg", "Load File", VAL_LOAD_BUTTON, 0, 1, 1, 0, szFile))
            { // Got File
                iRet = DisplayImageFile(panel, PNL_MAIN_IMG_CAMERA, szFile);
                
                SetCtrlVal(panel, PNL_MAIN_TXT_IMG_FILE, szFile);
            } // Got File
            break; // EVENT_COMMIT
    } // event
    return 0;
} // CVICALLBACK cbkDir
int CVICALLBACK cbkQuit (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
            QuitUserInterface (0);
            break;
    }
    return 0;
}
 mjl
		
			mjl
		
		
		
		
		
		
		
		
	
			01-11-2013 12:19 PM
I forgot to attach the .uir file, here it is.
 D_Biel
		
			D_Biel
		
		
		
		
		
		
		
		
	
			01-16-2013 02:54 PM - edited 01-16-2013 03:12 PM
Hi mjl,
I did see some pretty hefty memory usage when using a 12MP image (4000x3000). Part of the problem is that the 5MB JPG is compressed. Internally, CVI handles it as a bitmap as mentioned previously. If you convert the 5MB image to a bitmap, it ends up being about 34MB. A large chunk of memory, but not too likely to crash your system. However, we also copy that bitmap around internally before it is finally posted to the display and the memory is cleaned up. So there are multiple copies of this bitmap in memory at certain points in the process. I've filed a bug report to see if we can find a more efficient method to handle these multiple copies.
How much memory is the application using on the Win 7 system?
Are you doing any image processing on this image? If not, then you may want to consider downsizing the image for display unless you have a really large screen to display it on.
Edit: It is an RGB bitmap, not an RGBA. So the size is only 34MB.