mm_utils.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /****************************************************************************
  2. *
  3. * MODULE: iostream
  4. *
  5. * COPYRIGHT (C) 2007 Laura Toma
  6. *
  7. *
  8. * Iostream is a library that implements streams, external memory
  9. * sorting on streams, and an external memory priority queue on
  10. * streams. These are the fundamental components used in external
  11. * memory algorithms.
  12. * Credits: The library was developed by Laura Toma. The kernel of
  13. * class STREAM is based on the similar class existent in the GPL TPIE
  14. * project developed at Duke University. The sorting and priority
  15. * queue have been developed by Laura Toma based on communications
  16. * with Rajiv Wickremesinghe. The library was developed as part of
  17. * porting Terraflow to GRASS in 2001. PEARL upgrades in 2003 by
  18. * Rajiv Wickremesinghe as part of the Terracost project.
  19. *
  20. * This program is free software; you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation; either version 2 of the License, or
  23. * (at your option) any later version.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  28. * General Public License for more details. *
  29. * **************************************************************************/
  30. #include <sys/types.h>
  31. #include <ctype.h>
  32. #include <ostream>
  33. #include <iostream>
  34. #include <stdio.h>
  35. //#include <mm.h>
  36. #include <grass/iostream/mm.h>
  37. void
  38. LOG_avail_memo() {
  39. size_t sz_avail=0;
  40. sz_avail = MM_manager.memory_available();
  41. printf("available memory: %.2fMB\n", sz_avail/(float)(1<<20));
  42. }
  43. size_t
  44. getAvailableMemory() {
  45. size_t fmem;
  46. fmem = MM_manager.memory_available();
  47. return fmem;
  48. }
  49. void
  50. MEMORY_LOG(const std::string &str) {
  51. printf("%s", str.c_str());
  52. fflush(stdout);
  53. }