Go to Post Nothing worth gaining was ever obtained without effort. - Jaine Perotti [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-01-2012, 11:35
malachias malachias is offline
Registered User
FRC #1311
 
Join Date: Jan 2012
Location: Kell High School, Marietta, GA
Posts: 9
malachias is on a distinguished road
IMAQ images and Memory Management

I have not seen any code that disposed of Image instances (i.e., GetImaqImage()). I do, however, see code delete the source image and then use the underlying Image instance, which leads me to believe that ImageBase is not the owner of the Image instance. Am I to assume that they are managed by the IMAQ vision library. I can see generating a lot of these Images during a competition and although they tend to be small I can easily run out of memory if the resource is not freed.

Thanks
Reply With Quote
  #2   Spotlight this post!  
Unread 24-01-2012, 11:42
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: IMAQ images and Memory Management

Destructor of ImageBase:

Code:
ImageBase::~ImageBase()
{
	if(m_imaqImage)
		imaqDispose(m_imaqImage);
}
Snippet from header:

Code:
protected:
	Image *m_imaqImage;
Reply With Quote
  #3   Spotlight this post!  
Unread 26-01-2012, 00:00
Tommy.Brown's Avatar
Tommy.Brown Tommy.Brown is offline
Lead Programmer
FRC #1477 (Texas Torque)
Team Role: Programmer
 
Join Date: Jul 2011
Rookie Year: 2011
Location: The Woodlands
Posts: 27
Tommy.Brown is an unknown quantity at this point
Re: IMAQ images and Memory Management

If you are working with pointers, you should just be able to delete the images out of memory each time through the loop once you are done processing them.

Image *genericImage = NULL;
//Code to get value and store it in genericImage
delete genericImage;
__________________
FRC Team 1477 - Texas Torque
The Woodlands, Texas
Reply With Quote
  #4   Spotlight this post!  
Unread 26-01-2012, 00:04
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: IMAQ images and Memory Management

Quote:
Originally Posted by Tommy.Brown View Post
If you are working with pointers, you should just be able to delete the images out of memory each time through the loop once you are done processing them.

Image *genericImage = NULL;
//Code to get value and store it in genericImage
delete genericImage;
For Image objects you should use imaqDispose.
Reply With Quote
  #5   Spotlight this post!  
Unread 26-01-2012, 00:25
Tommy.Brown's Avatar
Tommy.Brown Tommy.Brown is offline
Lead Programmer
FRC #1477 (Texas Torque)
Team Role: Programmer
 
Join Date: Jul 2011
Rookie Year: 2011
Location: The Woodlands
Posts: 27
Tommy.Brown is an unknown quantity at this point
Re: IMAQ images and Memory Management

Ah, I have yet to look into the inner workings of the 7000 lines of nivision.h... I just went off of my prior C++ experience. Sorry for the misinformation.
__________________
FRC Team 1477 - Texas Torque
The Woodlands, Texas
Reply With Quote
  #6   Spotlight this post!  
Unread 26-01-2012, 08:31
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: IMAQ images and Memory Management

There are versions of GetImage that take a pointer to an Image so you can allocate your own image data structure (once using new HSLImage() then set the size) and use it over and over again. This will be a bit faster. When programming in a real-time environment it is better to NOT be doing memory allocations or formatted output in loops where you hope to have deterministic (execute in the same amount of time each time through) performance.

HTH
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:03.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi