Posted: 9th Jul 2022 19:08
I have read the other threads about this function, and it is working for me. However, it appears that DeleteVideo() is not working. As I watch in debug mode (Visual Studio 17) I can see the memory usage increase when loading the video but it doesn't decrease after DeleteVideo(). I set a breakpoint on the line for DeleteVideo(), so I know it is being executed.

I went so far as to set a breakpoint for every LoadVideo() and DeleteVideo() to make sure there was a Delete for every Load. All is looking good there. I also monitored the images, sprites and sound... all of which are being deleted after use (I have code that lists images, sprites and sounds by ID number). Everything is accounted for except the memory issue when I play video.

The manual states that we do not need to delete the image that is used by PlayVideoToImage(77), but I tried that resulting in a message trap stating that image 77 does not exist. Which would make sense if DeleteVideo() is taking care of that.

Anyone else experience this memory issue using PlayVideoToImage()?
Posted: 9th Jul 2022 21:34
After using TaskManager to monitor memory instead of relying only on VS17, I found that there is a return to nominal memory usage after DeleteVideo(). For some reason VS17 is showing a 300-400 MB increase for each video but does not return to nominal after DeleteVideo().

Even though Task Manager is showing a decrease after DeleteVideo(), there is still a 22MB increase from before the video played.
Posted: 10th Jul 2022 16:05
Interesting, I just tried with a ~130mb video file and the difference after deleting was a +2mb. I do not get the exact same values every time the below clip is from one run:

Posted: 10th Jul 2022 19:32
Since I was in scrutinize mode, I noticed that I saw an increase in memory usage every time I clicked the mouse button. About 100K every click.
I isolated it down to a bit of code I use to read a file then parse the data. I could not see why it was increasing memory usage. As an experiment, I swapped all the AppGameKit string functions to C++ functions, and now the issue is gone. Something weird is going on with the string functions: Left(), Right(), Mid() and Asc(). I knew about Str() where we need to assign to char* then delete[] the string. But I found nothing about the other string functions having similar protocols.
such as:
+ Code Snippet
char* strTemp = agk::Str(objExists);
MainLoop.locOBJ = "_OBJ" + string(strTemp);
delete[] strTemp;


Now, it takes 10 clicks instead of 1 to see a 100K change. I am sure this is due to my replacing all the string functions except for Asc().

Code after swapping to C++ functions:
+ Code Snippet
string GetParameter(std::string paraName, std::string fileName)
{
	string stuff;
	string theRest;
	string isolated;
	string testIT;
	int testIT2;
	stuff = "";
	theRest = "";
	isolated = "";
	agk::SetFolder("");
	agk::SetFolder("media");
	if (agk::GetFileExists(fileName.c_str()))
	{
		agk::OpenToRead(1, fileName.c_str());
		stuff = agk::ReadString(1);

		paraName = paraName + "=";
		for (unsigned int i = 0; i <= (stuff.length()); i++)
		{
			//if (agk::Mid(stuff.c_str(), i, (paraName.length())) == paraName)
			//{
			//	theRest = agk::Mid(stuff.c_str(), i + agk::Len(paraName.c_str()), (stuff.length()) - i);
			//	break;
			//}
			testIT=stuff.substr(i, paraName.length());
			if ((stuff.substr(i,paraName.length()) ) == paraName)
			{
				theRest = stuff.substr(i + paraName.length(), (stuff.length()) - i);
				break;
			}
		}

		for (unsigned int i = 0; i <= (theRest.length()); i++)
		{
			testIT2 = agk::Asc((theRest.substr(i, 1)).c_str());
			if ((agk::Asc((theRest.substr(i, 1)).c_str()) == 10) || ((agk::Asc((theRest.substr(i, 1)).c_str()) == 13)))
			{
				isolated = theRest.substr(0,i);
				break;
			}
		}
		agk::CloseFile(1);
	}
	return isolated;
}