| 1 | /********************************************************************** |
| 2 | testMemoryLeak.cc: test app for jiblib detecting memory leaks |
| 3 | Author(s): [email protected] |
| 4 | Copyright (C) 2016-2020 European Union (Joint Research Centre) |
| 5 | |
| 6 | This file is part of jiplib. |
| 7 | |
| 8 | jiplib is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | jiplib is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with jiplib. If not, see <https://www.gnu.org/licenses/>. |
| 20 | ***********************************************************************/ |
| 21 | #include <memory> |
| 22 | #include <string> |
| 23 | #include "base/Optionjl.h" |
| 24 | #include "algorithms/StatFactory.h" |
| 25 | #include "imageclasses/Jim.h" |
| 26 | |
| 27 | using namespace std; |
| 28 | using namespace statfactory; |
| 29 | |
| 30 | int main(int argc, char *argv[]) |
| 31 | { |
| 32 | Optionjl<int> number_opt("n", "number", "Number of images to create for memory test",10); |
| 33 | Optionjl<unsigned long int> memory_opt("mem", "mem", "Buffer size (in MB) to read image data blocks in memory",0,1); |
| 34 | |
| 35 | memory_opt.setHide(1); |
| 36 | try{ |
| 37 | bool doProcess;//stop process when program was invoked with help option (-h --help) |
| 38 | app::AppFactory app(argc,argv); |
| 39 | |
| 40 | doProcess=number_opt.retrieveOption(app); |
| 41 | memory_opt.retrieveOption(app); |
| 42 | |
| 43 | std::shared_ptr<Jim> imgRaster1; |
| 44 | std::shared_ptr<Jim> imgRaster2; |
| 45 | for(int i=0;i<number_opt[0];++i){ |
| 46 | std::cout << "Creating shared pointer to image " << i << std::endl; |
| 47 | imgRaster1=Jim::createImg(app); |
| 48 | imgRaster2=Jim::createImg(app); |
| 49 | std::cout << "Number of rows, cols, bands: " << imgRaster1->nrOfRow() << ", " << imgRaster1->nrOfCol() << ", " << imgRaster1->nrOfBand() << std::endl; |
| 50 | // std::cout << "getMax(): " << imgRaster->getMax() << std::endl; |
| 51 | imgRaster1->close(); |
| 52 | std::cout << "Number of rows, cols, bands: " << imgRaster2->nrOfRow() << ", " << imgRaster2->nrOfCol() << ", " << imgRaster2->nrOfBand() << std::endl; |
| 53 | // imgRaster2->close(); |
| 54 | } |
| 55 | } |
| 56 | catch(string helpString){ |
| 57 | cerr << helpString << endl; |
| 58 | cout << "Usage: testMemoryLeak -nrow rows -ncol rows [-nband bands] -n number" << endl; |
| 59 | return(1); |
| 60 | } |
| 61 | std::cout << "testMemoryLeak: done" << std::endl; |
| 62 | return(0); |
| 63 | } |