Skip to content

Commit

Permalink
Camstudio v2.6, release 273:
Browse files Browse the repository at this point in the history
------------------------------
Fixed a memoryleak that caused Camstudio crashed after 40-50 minutes of recording.
Redesigned the region calculation routines.
* The same procedure is now applicable for all sizing calculations.
* The area you define in regions is the area that will be recorded. No shift in position or losing rows or columns.
* Size of the region is now displayed correctly in the progress monitoring window.
* Size of the recording is now equal to the size as displayed the progress monitoring window.
  • Loading branch information
janhgm committed Oct 5, 2010
1 parent 6d72670 commit 5b76cfa
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CamStudio/Recorder/Camstudio4XNote.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// Define CAMSTUDIO4XNOTE if this is a custom build release for Xnote Stopwatch users (2010/05/28, Janhgm)
// Setting this defines will preconfigure a few innitial settings
#define CAMSTUDIO4XNOTE
// #define CAMSTUDIO4XNOTE


// Stopwatch sources applications
Expand Down
4 changes: 3 additions & 1 deletion CamStudio/Recorder/LayoutList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ BOOL CLayoutList::LoadLayoutFromFile(FILE *fptr)

}

if (layoutArrayPtr==NULL)
if (layoutArrayPtr==NULL) {
// TODO, Possible memory leak, where is the delete operation of the new below done?
layoutArrayPtr = new CArray<CTransparentWnd *,CTransparentWnd *>;
}
ListManager.LoadLayoutArrayFromFile(layoutArrayPtr , fptr);

if (layoutversion>1)
Expand Down
6 changes: 6 additions & 0 deletions CamStudio/Recorder/ListManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ int CListManager::LoadShapeArray(CString loadDir, int freeExisting)
FreeShapeArray();
}
for (int i = 0; i < max; i++) {
// TODO, Possible memory leak, where is the delete operation of the new below done?
CTransparentWnd * itemWnd = new CTransparentWnd;
if (itemWnd) {
if (!itemWnd->LoadShape(fptr)) {
Expand Down Expand Up @@ -301,6 +302,7 @@ int CListManager::DestroyArrayItems(CArray<CTransparentWnd *,CTransparentWnd *>

CArray<CTransparentWnd *,CTransparentWnd *> * CListManager::CloneDisplayArray()
{
// TODO, Possible memory leak, where is the delete operation of the new below done?
CArray<CTransparentWnd *,CTransparentWnd *> *cloneArray = new CArray<CTransparentWnd *,CTransparentWnd *>;

int max = displayArray.GetSize();
Expand Down Expand Up @@ -349,6 +351,7 @@ int CListManager::FreeLayoutArray()
CArray<CTransparentWnd *,CTransparentWnd *> * CListManager::CloneLayoutArrayPtr(CLayoutList* itemLayout)
{
CArray<CTransparentWnd *,CTransparentWnd *> * layoutArrayPtr = itemLayout->layoutArrayPtr;
// TODO, Possible memory leak, where is the delete operation of the new below done?
CArray<CTransparentWnd *,CTransparentWnd *> *cloneArray = new CArray<CTransparentWnd *,CTransparentWnd *>;

int max = layoutArrayPtr->GetSize();
Expand All @@ -373,6 +376,7 @@ CLayoutList * CListManager::CloneLayout(CLayoutList * itemLayout)
if (itemLayout) {
CArray<CTransparentWnd *,CTransparentWnd *> *cloneArray = CloneLayoutArrayPtr(itemLayout);
if (cloneArray) {
// TODO, Possible memory leak, where is the delete operation of the new below done?
newLayout = new CLayoutList;
if (newLayout) {
newLayout->layoutArrayPtr = cloneArray;
Expand Down Expand Up @@ -482,6 +486,7 @@ int CListManager::LoadLayout(CString loadDir)
FreeLayoutArray();
for (int i=0; i<max; i++)
{
// TODO, Possible memory leak, where is the delete operation of the new below done?
CLayoutList * itemLayout = new CLayoutList;
if (itemLayout) {
if (!itemLayout->LoadLayoutFromFile(fptr)) {
Expand Down Expand Up @@ -605,6 +610,7 @@ int CListManager::LoadLayoutArrayFromFile(CArray<CTransparentWnd *,CTransparentW
if ((max > 0) && (max<10000)) {
for (int i=0; i<max; i++)
{
// TODO, Possible memory leak, where is the delete operation of the new below done?
CTransparentWnd * itemWnd = new CTransparentWnd;
if (itemWnd) {
if (!itemWnd->LoadShape(fptr)) {
Expand Down
1 change: 1 addition & 0 deletions CamStudio/Recorder/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ bool sAudioFormat::NewAudio()
return bResult;
}

// TODO, Possible memory leak, where is the delete operation of the new below done?
m_pwfx = (LPWAVEFORMATEX)new char[m_dwCbwFX];
bResult = (0 != m_pwfx);
if (!bResult) {
Expand Down
1 change: 1 addition & 0 deletions CamStudio/Recorder/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ struct sVideoOpts
return m_pState;
}
m_dwCompressorStateSize = dwStateSize;
// TODO, Possible memory leak, where is the delete operation of the new below done?
m_pState = new char[m_dwCompressorStateSize];
return m_pState;
}
Expand Down
1 change: 1 addition & 0 deletions CamStudio/Recorder/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ BOOL CRecorderApp::InitInstance()
// serve as the connection between documents, frame windows and views.

CSingleDocTemplate* pDocTemplate;
// TODO, Possible memory leak, where is the delete operation of the new below done?
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CRecorderDoc),
Expand Down
19 changes: 18 additions & 1 deletion CamStudio/Recorder/Recorder.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Recorder.h : main header file for the VSCAP application
// Recorder.h : main header file for the Recorder (before known as VSCAP) application
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_VSCAP_H__CAB648E2_684F_4FF1_B574_9714ACAC6D57__INCLUDED_)
Expand All @@ -12,6 +12,23 @@
#error include 'stdafx.h' before including this file for PCH
#endif

#ifdef _DEBUG
// VISUAL LEAK DETECTOR by Dan Moulding (dmoulding@gmail.com)
// Enhanced Memory Leak Detection for Visual C++
// Requires that Visual Leak Detector (vld) is installed and include and library are add to MSVS toolbox (see vld instructions)
// BTW. vld requires dbghelp.dll and msvcr80.dll. These are not included within the distribution of vld.
// http://www.codeproject.com/KB/applications/visualleakdetector.aspx
// http://sites.google.com/site/dmoulding/vld
//
// Because vld requires a lot of memory it self and can slow down performance the default state is that we do not keep it acticated all the time.
// If you want to debug a certain source you can copy the include below in the file you wat to validate.
//
//#define _VISUALLEAKDETECTOR
#ifdef _VISUALLEAKDETECTOR
#include <vld.h>
#endif
#endif

#include "CamError.h"
#include "CamStudioCommandLineInfo.h"
#include "Profile.h"
Expand Down
12 changes: 6 additions & 6 deletions CamStudio/Recorder/Recorder.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
MinimalRebuild="true"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/vscap.pch"
PrecompiledHeaderFile=".\Debug/recorder.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
Expand Down Expand Up @@ -187,7 +187,7 @@
ManifestFile="$(SolutionDir)$(ConfigurationName)\$(TargetFileName).intermediate.manifest"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/vscap.pdb"
ProgramDatabaseFile=".\Debug/recorder.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
Expand Down Expand Up @@ -639,11 +639,11 @@
>
</File>
<File
RelativePath="..\GlobalResources\Recorder.ico"
RelativePath=".\Recorder.ico"
>
</File>
<File
RelativePath=".\Recorder.ico"
RelativePath="..\GlobalResources\Recorder.ico"
>
</File>
<File
Expand All @@ -659,11 +659,11 @@
>
</File>
<File
RelativePath=".\Recorder_logo.bmp"
RelativePath="..\GlobalResources\Recorder_logo.bmp"
>
</File>
<File
RelativePath="..\GlobalResources\Recorder_logo.bmp"
RelativePath=".\Recorder_logo.bmp"
>
</File>
<File
Expand Down
2 changes: 1 addition & 1 deletion CamStudio/Recorder/RecorderVersionReleaseInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
#define CURRENT_VERSION_NUMBER "2.6"
// Add ++ to releasenumber to indicate that executable is from revision xxx or higher
// Update versionnumber and remove ++ when official Camstudio release will be created
#define CURRENT_SVN_RELEASE_NUMBER "272"
#define CURRENT_SVN_RELEASE_NUMBER "273"

#endif // !defined(_RECORDERVERSIONRELEASEINFO__INCLUDED_)
22 changes: 17 additions & 5 deletions CamStudio/Recorder/RecorderView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
#include "XnoteStopwatchFormat.h"
#include "Camstudio4XNote.h"

#ifdef _DEBUG
// #include <vld.h> // Visual Leak Detector utility (In debug mode)
#endif

#include <windowsx.h>
#include <fstream>
#include <iostream>
Expand Down Expand Up @@ -1234,10 +1238,10 @@ void CRecorderView::OnRecord()
// Applicable when Option region is set as 'Fixed Region'


rc = CRect(cRegionOpts.m_iCaptureTop,
cRegionOpts.m_iCaptureLeft,
cRegionOpts.m_iCaptureLeft + cRegionOpts.m_iCaptureWidth - 1 ,
cRegionOpts.m_iCaptureTop + cRegionOpts.m_iCaptureHeight - 1 );
rc = CRect(cRegionOpts.m_iCaptureLeft, // X = Left
cRegionOpts.m_iCaptureTop, // Y = Top
cRegionOpts.m_iCaptureLeft + cRegionOpts.m_iCaptureWidth - 1 , // X = Width
cRegionOpts.m_iCaptureTop + cRegionOpts.m_iCaptureHeight - 1 ); // Y = Height

// TRACE( _T("## CRecorderView::OnRecord /CAPTURE_FIXED/ before / rc / T=%d, L=%d, B=%d, R=%d \n"), rc.top, rc.left, rc.bottom, rc.right );

Expand Down Expand Up @@ -1294,6 +1298,8 @@ void CRecorderView::OnRecord()
case CAPTURE_WINDOW:
case CAPTURE_FULLSCREEN:
// Applicable when Option region is set as 'Window' and as 'Full Screen'

// TODO, Possible memory leak, where is the delete operation of the new below done?
m_basicMsg = new CBasicMessage();
m_basicMsg->Create(CBasicMessage::IDD);
m_basicMsg->SetText(_T("Click on window to be captured."));
Expand Down Expand Up @@ -1338,8 +1344,11 @@ void CRecorderView::OnFileVideooptions()
LPBITMAPINFOHEADER first_alpbi = captureScreenFrame(rect) ? m_cCamera.Image() : 0;

num_compressor = 0;
if (pCompressorInfo)
if (pCompressorInfo) {
delete [] pCompressorInfo;
}

// TODO, Possible memory leak, where is the delete operation of the new below done?
pCompressorInfo = new ICINFO[MAXCOMPRESSORS];

//for (int i = 0; ICInfo(ICTYPE_VIDEO, i, &pCompressorInfo[num_compressor]); i++) {
Expand Down Expand Up @@ -2846,6 +2855,7 @@ void CRecorderView::OnViewVideoannotations()

rect.left = x;
rect.top = y;
// TODO, Magic values here again 160,120
rect.right = rect.left + 160 - 1;
rect.bottom = rect.top + 120 - 1;
m_vanWnd.TextString(m_newShapeText);
Expand Down Expand Up @@ -4693,6 +4703,7 @@ void DataFromSoundIn(CBuffer* buffer)
int AddInputBufferToQueue()
{
// create the header
// TODO, Possible memory leak, where is the delete operation of the new below done?
LPWAVEHDR pHdr = new WAVEHDR;
if (pHdr == NULL) {
return NULL;
Expand Down Expand Up @@ -4765,6 +4776,7 @@ BOOL InitAudioRecording()

//Create temporary wav file for audio recording
GetTempAudioWavPath();
// TODO, Possible memory leak, where is the delete operation of the new below done?
pSoundFile = new CSoundFile(strTempAudioWavFilePath, &(cAudioFormat.AudioFormat()));

if (!(pSoundFile && pSoundFile->IsOK()))
Expand Down
4 changes: 4 additions & 0 deletions CamStudio/Recorder/ScreenAnnotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ void CScreenAnnotationsDlg::OnEditobjNewobject()
CNewShapeDlg newshapeDlg;
if (newshapeDlg.DoModal() == IDOK) {
CTransparentWnd *newWnd;

// TODO, Possible memory leak, where is the delete operation of the new below done?
newWnd = new CTransparentWnd;

int x = (rand() % 100) + 100;
Expand Down Expand Up @@ -425,6 +427,8 @@ void CScreenAnnotationsDlg::SaveLayoutNew()
if (cloneArray)
{
CLayoutList * newLayout = NULL;

// TODO, Possible memory leak, where is the delete operation of the new below done?
newLayout = new CLayoutList;
if (newLayout)
{
Expand Down
3 changes: 2 additions & 1 deletion CamStudio/Recorder/StdAfx.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// vscap.pch will be the pre-compiled header
// vscap.pch will be the pre-compiled header
// .. Remark: Although vscap.cpp and vscap.h are renamed and are now recorder.???, this vscap.pch file is still created and still use the old naming either.
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"
Expand Down
4 changes: 2 additions & 2 deletions CamStudio/Recorder/TransparentWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ BOOL CTransparentWnd::LoadShape(FILE* fptr)
fread( (void *) &len, sizeof(int), 1, fptr );
if ((0 < len) && (len < 100000)) {
//char *buf = (char *) malloc(len + 2);
char *buf = new char[len + 2];
char *buf = new char[len + 2]; // No memory leak here, buf is deleted in this block of code too
fread(buf, len, 1, fptr );
buf[len] = 0;
buf[len+1] = 0;
Expand All @@ -1412,7 +1412,7 @@ BOOL CTransparentWnd::LoadShape(FILE* fptr)
fread( (void *) &len, sizeof(int), 1, fptr );
if ((len>0) && (len<100000)) {
//char *buf = (char *) malloc(len + 2);
char *buf = new char[len + 2];
char *buf = new char[len + 2]; // No memory leak here, buf is deleted in this block of code too
fread( (void *) buf, len, 1, fptr );
buf[len] = 0;
buf[len+1] = 0;
Expand Down
1 change: 1 addition & 0 deletions CamStudio/Recorder/VCM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ bool CHIC::getState()
return bResult;
}

// TODO, Possible memory leak, where is the delete operation of the new below done although there is a delete in catch
m_pState = new char[m_ulStateSize];
LRESULT lResult = ::ICGetState(m_hIC, m_pState, m_ulStateSize);
// bResult = (lResult == m_ulStateSize ); ==> C4389 Warning, type mismatch
Expand Down

0 comments on commit 5b76cfa

Please sign in to comment.