<commit_before>package azkaban.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

/**
 * @author wkang
 * This class is used to maintain system memory information. Processes utilizing
 * large amount of memory should consult this class to see if the system has enough
 * memory to proceed the operation.
 * 
 * Memory information is obtained from /proc/meminfo, so only Unix/Linux like system
 * will support this class.
 * 
 * All the memory size used in this function is in KB
 */
public class SystemMemoryInfo {
  private static final Logger logger = Logger.getLogger(SystemMemoryInfo.class);

  private static String MEMINFO_FILE = "/proc/meminfo"; 
  private static boolean memCheckEnabled;
  private static long freeMemAmount = 0;
  private static final long LOW_MEM_THRESHOLD = 3L*1024L*1024L; //3 GB

  private static ScheduledExecutorService scheduledExecutorService;

  public static void init(int memCheckInterval) {
    File f = new File(MEMINFO_FILE);
    memCheckEnabled = f.exists() && !f.isDirectory();
    if (memCheckEnabled) {
      //initial reading of the mem info
      readMemoryInfoFile();

      //schedule a thread to read it
      logger.info(String.format("Scheduled thread to read /proc/meminfo every %d seconds", memCheckInterval));
      scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
      scheduledExecutorService.scheduleAtFixedRate(new MemoryInfoReader(), 0, memCheckInterval, TimeUnit.SECONDS);
    } else {
      logger.info("Cannot find /proc/meminfo, memory check will be disabled");
    }
  }

  /**
   * @param xms<commit_msg>修改内存大小<commit_after>package azkaban.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

/**
 * @author wkang
 * This class is used to maintain system memory information. Processes utilizing
 * large amount of memory should consult this class to see if the system has enough
 * memory to proceed the operation.
 * 
 * Memory information is obtained from /proc/meminfo, so only Unix/Linux like system
 * will support this class.
 * 
 * All the memory size used in this function is in KB
 */
public class SystemMemoryInfo {
  private static final Logger logger = Logger.getLogger(SystemMemoryInfo.class);

  private static String MEMINFO_FILE = "/proc/meminfo"; 
  private static boolean memCheckEnabled;
  private static long freeMemAmount = 0;
    //modified start----------------
    //modified by <EMAIL>
    //修改了最低内存限制原值:  3L*1024L*1024L
//  private static final long LOW_MEM_THRESHOLD = 3L*1024L*1024L; //3 GB
    private static final long LOW_MEM_THRESHOLD = 200L*1024L; //200 M
    //modified end-------------------
  private static ScheduledExecutorService scheduledExecutorService;

  public static void init(int memCheckInterval) {
    File f = new File(MEMINFO_FILE);
    memCheckEnabled = f.exists() && !f.isDirectory();
    if (memCheckEnabled) {
      //initial reading of the mem info
      readMemoryInfoFile();

      //schedule a thread to read it
      logger.info(String.format("Scheduled thread to read /proc/meminfo every %d seconds", memCheckInterval));
      scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
      scheduledExecutorService.scheduleAtFixedRate(new MemoryInfoReader(), 0, memCheckInterval, TimeUnit.SECONDS);
    } else {
      logger.info("Cannot find /proc/meminfo, memory check will be disabled");
    }
  }

  /**
   * @param xms
{'fraction_non_alphanumeric': 0.09339229968782518, 'fraction_numerical': 0.011706555671175858, 'mean_word_length': 3.9043367346938775, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5324877', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1059, 'n_words': 348}