Skip to content

Commit 5b76cfa

Browse files
author
janhgm
committed
Camstudio v2.6, release 273:
------------------------------ 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.
1 parent 6d72670 commit 5b76cfa

14 files changed

+64
-18
lines changed

CamStudio/Recorder/Camstudio4XNote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

1010

1111
// Stopwatch sources applications

CamStudio/Recorder/LayoutList.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ BOOL CLayoutList::LoadLayoutFromFile(FILE *fptr)
8181

8282
}
8383

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

8890
if (layoutversion>1)

CamStudio/Recorder/ListManager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ int CListManager::LoadShapeArray(CString loadDir, int freeExisting)
117117
FreeShapeArray();
118118
}
119119
for (int i = 0; i < max; i++) {
120+
// TODO, Possible memory leak, where is the delete operation of the new below done?
120121
CTransparentWnd * itemWnd = new CTransparentWnd;
121122
if (itemWnd) {
122123
if (!itemWnd->LoadShape(fptr)) {
@@ -301,6 +302,7 @@ int CListManager::DestroyArrayItems(CArray<CTransparentWnd *,CTransparentWnd *>
301302

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

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

354357
int max = layoutArrayPtr->GetSize();
@@ -373,6 +376,7 @@ CLayoutList * CListManager::CloneLayout(CLayoutList * itemLayout)
373376
if (itemLayout) {
374377
CArray<CTransparentWnd *,CTransparentWnd *> *cloneArray = CloneLayoutArrayPtr(itemLayout);
375378
if (cloneArray) {
379+
// TODO, Possible memory leak, where is the delete operation of the new below done?
376380
newLayout = new CLayoutList;
377381
if (newLayout) {
378382
newLayout->layoutArrayPtr = cloneArray;
@@ -482,6 +486,7 @@ int CListManager::LoadLayout(CString loadDir)
482486
FreeLayoutArray();
483487
for (int i=0; i<max; i++)
484488
{
489+
// TODO, Possible memory leak, where is the delete operation of the new below done?
485490
CLayoutList * itemLayout = new CLayoutList;
486491
if (itemLayout) {
487492
if (!itemLayout->LoadLayoutFromFile(fptr)) {
@@ -605,6 +610,7 @@ int CListManager::LoadLayoutArrayFromFile(CArray<CTransparentWnd *,CTransparentW
605610
if ((max > 0) && (max<10000)) {
606611
for (int i=0; i<max; i++)
607612
{
613+
// TODO, Possible memory leak, where is the delete operation of the new below done?
608614
CTransparentWnd * itemWnd = new CTransparentWnd;
609615
if (itemWnd) {
610616
if (!itemWnd->LoadShape(fptr)) {

CamStudio/Recorder/Profile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ bool sAudioFormat::NewAudio()
7979
return bResult;
8080
}
8181

82+
// TODO, Possible memory leak, where is the delete operation of the new below done?
8283
m_pwfx = (LPWAVEFORMATEX)new char[m_dwCbwFX];
8384
bResult = (0 != m_pwfx);
8485
if (!bResult) {

CamStudio/Recorder/Profile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ struct sVideoOpts
804804
return m_pState;
805805
}
806806
m_dwCompressorStateSize = dwStateSize;
807+
// TODO, Possible memory leak, where is the delete operation of the new below done?
807808
m_pState = new char[m_dwCompressorStateSize];
808809
return m_pState;
809810
}

CamStudio/Recorder/Recorder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ BOOL CRecorderApp::InitInstance()
239239
// serve as the connection between documents, frame windows and views.
240240

241241
CSingleDocTemplate* pDocTemplate;
242+
// TODO, Possible memory leak, where is the delete operation of the new below done?
242243
pDocTemplate = new CSingleDocTemplate(
243244
IDR_MAINFRAME,
244245
RUNTIME_CLASS(CRecorderDoc),

CamStudio/Recorder/Recorder.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Recorder.h : main header file for the VSCAP application
1+
// Recorder.h : main header file for the Recorder (before known as VSCAP) application
22
//
33
/////////////////////////////////////////////////////////////////////////////
44
#if !defined(AFX_VSCAP_H__CAB648E2_684F_4FF1_B574_9714ACAC6D57__INCLUDED_)
@@ -12,6 +12,23 @@
1212
#error include 'stdafx.h' before including this file for PCH
1313
#endif
1414

15+
#ifdef _DEBUG
16+
// VISUAL LEAK DETECTOR by Dan Moulding (dmoulding@gmail.com)
17+
// Enhanced Memory Leak Detection for Visual C++
18+
// Requires that Visual Leak Detector (vld) is installed and include and library are add to MSVS toolbox (see vld instructions)
19+
// BTW. vld requires dbghelp.dll and msvcr80.dll. These are not included within the distribution of vld.
20+
// http://www.codeproject.com/KB/applications/visualleakdetector.aspx
21+
// http://sites.google.com/site/dmoulding/vld
22+
//
23+
// 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.
24+
// If you want to debug a certain source you can copy the include below in the file you wat to validate.
25+
//
26+
//#define _VISUALLEAKDETECTOR
27+
#ifdef _VISUALLEAKDETECTOR
28+
#include <vld.h>
29+
#endif
30+
#endif
31+
1532
#include "CamError.h"
1633
#include "CamStudioCommandLineInfo.h"
1734
#include "Profile.h"

CamStudio/Recorder/Recorder.vcproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
MinimalRebuild="true"
157157
RuntimeLibrary="3"
158158
UsePrecompiledHeader="2"
159-
PrecompiledHeaderFile=".\Debug/vscap.pch"
159+
PrecompiledHeaderFile=".\Debug/recorder.pch"
160160
AssemblerListingLocation=".\Debug/"
161161
ObjectFile=".\Debug/"
162162
ProgramDataBaseFileName=".\Debug/"
@@ -187,7 +187,7 @@
187187
ManifestFile="$(SolutionDir)$(ConfigurationName)\$(TargetFileName).intermediate.manifest"
188188
IgnoreDefaultLibraryNames=""
189189
GenerateDebugInformation="true"
190-
ProgramDatabaseFile=".\Debug/vscap.pdb"
190+
ProgramDatabaseFile=".\Debug/recorder.pdb"
191191
SubSystem="2"
192192
RandomizedBaseAddress="1"
193193
DataExecutionPrevention="0"
@@ -639,11 +639,11 @@
639639
>
640640
</File>
641641
<File
642-
RelativePath="..\GlobalResources\Recorder.ico"
642+
RelativePath=".\Recorder.ico"
643643
>
644644
</File>
645645
<File
646-
RelativePath=".\Recorder.ico"
646+
RelativePath="..\GlobalResources\Recorder.ico"
647647
>
648648
</File>
649649
<File
@@ -659,11 +659,11 @@
659659
>
660660
</File>
661661
<File
662-
RelativePath=".\Recorder_logo.bmp"
662+
RelativePath="..\GlobalResources\Recorder_logo.bmp"
663663
>
664664
</File>
665665
<File
666-
RelativePath="..\GlobalResources\Recorder_logo.bmp"
666+
RelativePath=".\Recorder_logo.bmp"
667667
>
668668
</File>
669669
<File

CamStudio/Recorder/RecorderVersionReleaseInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
#define CURRENT_VERSION_NUMBER "2.6"
99
// Add ++ to releasenumber to indicate that executable is from revision xxx or higher
1010
// Update versionnumber and remove ++ when official Camstudio release will be created
11-
#define CURRENT_SVN_RELEASE_NUMBER "272"
11+
#define CURRENT_SVN_RELEASE_NUMBER "273"
1212

1313
#endif // !defined(_RECORDERVERSIONRELEASEINFO__INCLUDED_)

CamStudio/Recorder/RecorderView.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#include "XnoteStopwatchFormat.h"
5151
#include "Camstudio4XNote.h"
5252

53+
#ifdef _DEBUG
54+
// #include <vld.h> // Visual Leak Detector utility (In debug mode)
55+
#endif
56+
5357
#include <windowsx.h>
5458
#include <fstream>
5559
#include <iostream>
@@ -1234,10 +1238,10 @@ void CRecorderView::OnRecord()
12341238
// Applicable when Option region is set as 'Fixed Region'
12351239

12361240

1237-
rc = CRect(cRegionOpts.m_iCaptureTop,
1238-
cRegionOpts.m_iCaptureLeft,
1239-
cRegionOpts.m_iCaptureLeft + cRegionOpts.m_iCaptureWidth - 1 ,
1240-
cRegionOpts.m_iCaptureTop + cRegionOpts.m_iCaptureHeight - 1 );
1241+
rc = CRect(cRegionOpts.m_iCaptureLeft, // X = Left
1242+
cRegionOpts.m_iCaptureTop, // Y = Top
1243+
cRegionOpts.m_iCaptureLeft + cRegionOpts.m_iCaptureWidth - 1 , // X = Width
1244+
cRegionOpts.m_iCaptureTop + cRegionOpts.m_iCaptureHeight - 1 ); // Y = Height
12411245

12421246
// 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 );
12431247

@@ -1294,6 +1298,8 @@ void CRecorderView::OnRecord()
12941298
case CAPTURE_WINDOW:
12951299
case CAPTURE_FULLSCREEN:
12961300
// Applicable when Option region is set as 'Window' and as 'Full Screen'
1301+
1302+
// TODO, Possible memory leak, where is the delete operation of the new below done?
12971303
m_basicMsg = new CBasicMessage();
12981304
m_basicMsg->Create(CBasicMessage::IDD);
12991305
m_basicMsg->SetText(_T("Click on window to be captured."));
@@ -1338,8 +1344,11 @@ void CRecorderView::OnFileVideooptions()
13381344
LPBITMAPINFOHEADER first_alpbi = captureScreenFrame(rect) ? m_cCamera.Image() : 0;
13391345

13401346
num_compressor = 0;
1341-
if (pCompressorInfo)
1347+
if (pCompressorInfo) {
13421348
delete [] pCompressorInfo;
1349+
}
1350+
1351+
// TODO, Possible memory leak, where is the delete operation of the new below done?
13431352
pCompressorInfo = new ICINFO[MAXCOMPRESSORS];
13441353

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

28472856
rect.left = x;
28482857
rect.top = y;
2858+
// TODO, Magic values here again 160,120
28492859
rect.right = rect.left + 160 - 1;
28502860
rect.bottom = rect.top + 120 - 1;
28512861
m_vanWnd.TextString(m_newShapeText);
@@ -4693,6 +4703,7 @@ void DataFromSoundIn(CBuffer* buffer)
46934703
int AddInputBufferToQueue()
46944704
{
46954705
// create the header
4706+
// TODO, Possible memory leak, where is the delete operation of the new below done?
46964707
LPWAVEHDR pHdr = new WAVEHDR;
46974708
if (pHdr == NULL) {
46984709
return NULL;
@@ -4765,6 +4776,7 @@ BOOL InitAudioRecording()
47654776

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

47704782
if (!(pSoundFile && pSoundFile->IsOK()))

CamStudio/Recorder/ScreenAnnotations.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ void CScreenAnnotationsDlg::OnEditobjNewobject()
343343
CNewShapeDlg newshapeDlg;
344344
if (newshapeDlg.DoModal() == IDOK) {
345345
CTransparentWnd *newWnd;
346+
347+
// TODO, Possible memory leak, where is the delete operation of the new below done?
346348
newWnd = new CTransparentWnd;
347349

348350
int x = (rand() % 100) + 100;
@@ -425,6 +427,8 @@ void CScreenAnnotationsDlg::SaveLayoutNew()
425427
if (cloneArray)
426428
{
427429
CLayoutList * newLayout = NULL;
430+
431+
// TODO, Possible memory leak, where is the delete operation of the new below done?
428432
newLayout = new CLayoutList;
429433
if (newLayout)
430434
{

CamStudio/Recorder/StdAfx.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// stdafx.cpp : source file that includes just the standard includes
2-
// vscap.pch will be the pre-compiled header
2+
// vscap.pch will be the pre-compiled header
3+
// .. 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.
34
// stdafx.obj will contain the pre-compiled type information
45

56
#include "stdafx.h"

CamStudio/Recorder/TransparentWnd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ BOOL CTransparentWnd::LoadShape(FILE* fptr)
14001400
fread( (void *) &len, sizeof(int), 1, fptr );
14011401
if ((0 < len) && (len < 100000)) {
14021402
//char *buf = (char *) malloc(len + 2);
1403-
char *buf = new char[len + 2];
1403+
char *buf = new char[len + 2]; // No memory leak here, buf is deleted in this block of code too
14041404
fread(buf, len, 1, fptr );
14051405
buf[len] = 0;
14061406
buf[len+1] = 0;
@@ -1412,7 +1412,7 @@ BOOL CTransparentWnd::LoadShape(FILE* fptr)
14121412
fread( (void *) &len, sizeof(int), 1, fptr );
14131413
if ((len>0) && (len<100000)) {
14141414
//char *buf = (char *) malloc(len + 2);
1415-
char *buf = new char[len + 2];
1415+
char *buf = new char[len + 2]; // No memory leak here, buf is deleted in this block of code too
14161416
fread( (void *) buf, len, 1, fptr );
14171417
buf[len] = 0;
14181418
buf[len+1] = 0;

CamStudio/Recorder/VCM.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ bool CHIC::getState()
7777
return bResult;
7878
}
7979

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

0 commit comments

Comments
 (0)