even after using this function
def optimize_dataframe_types(df):
    """
    Function to optimize DataFrame column types for memory efficiency.
    
    Parameters:
    df : pandas DataFrame
        The DataFrame to optimize.
        
    Returns:
    pandas DataFrame
        The DataFrame with optimized types.
    """
    for column in df.columns:
        # Check the data type of the column
        current_dtype = df[column].dtype
        print(f"Processing column: {column} - Current dtype: {current_dtype}")

        # Convert integer columns
        if pd.api.types.is_integer_dtype(current_dtype):
            # Check for maximum value for optimal casting
            if df[column].max() < 2**31 - 1:  # Less than int32 max
                df[column] = df[column].astype('int32')
                print(f"Converted {column} to int32")
            else:
                print(f"{column} retains original dtype: {current_dtype}")

        # Convert float columns
        elif pd.api.types.is_float_dtype(current_dtype):
            df[column] = df[column].astype('float32')
            print(f"Converted {column} to float32")

        # Convert object columns to category if they are suitable
        elif pd.api.types.is_object_dtype(current_dtype):
            # Convert to category
            df[column] = df[column].astype('category')
            print(f"Converted {column} to category")

    return df

# Example usage on merged_df_12_5 and merged_df_34
optimized_df_12_5 = optimize_dataframe_types(merged_df_12_5)
optimized_df_34 = optimize_dataframe_types(merged_df_34)

when i perform the merge operation i'm getting the following error
code:
# Merging plp_account_icomp (merged_df_12_5) with inforce_metlife_mapping (merged_df_34)

#Converting "cust_num" of merged_df_34 to object datatype initially it was float64
optimized_df_34['cust_num'] = optimized_df_34['cust_num'].astype('object')
merged_df_125_34 = pd.merge(optimized_df_12_5, optimized_df_34, left_on='Customer Number', right_on='cust_num', how='left')

MemoryError                               Traceback (most recent call last)
Cell In[8], line 5
      1 # Merging plp_account_icomp (merged_df_12_5) with inforce_metlife_mapping (merged_df_34)
      2 
      3 #Converting "cust_num" of merged_df_34 to object datatype initially it was float64
      4 optimized_df_34['cust_num'] = optimized_df_34['cust_num'].astype('object')
----> 5 merged_df_125_34 = pd.merge(optimized_df_12_5, optimized_df_34, left_on='Customer Number', right_on='cust_num', how='left')

File ~\gain\Lib\site-packages\pandas\core\reshape\merge.py:184, in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
    169 else:
    170     op = _MergeOperation(
    171         left_df,
    172         right_df,
   (...)
    182         validate=validate,
    183     )
--> 184     return op.get_result(copy=copy)

File ~\gain\Lib\site-packages\pandas\core\reshape\merge.py:886, in _MergeOperation.get_result(self, copy)
    883 if self.indicator:
    884     self.left, self.right = self._indicator_pre_merge(self.left, self.right)
--> 886 join_index, left_indexer, right_indexer = self._get_join_info()
    888 result = self._reindex_and_concat(
    889     join_index, left_indexer, right_indexer, copy=copy
    890 )
    891 result = result.__finalize__(self, method=self._merge_type)

File ~\gain\Lib\site-packages\pandas\core\reshape\merge.py:1151, in _MergeOperation._get_join_info(self)
   1147     join_index, right_indexer, left_indexer = _left_join_on_index(
   1148         right_ax, left_ax, self.right_join_keys, sort=self.sort
   1149     )
   1150 else:
-> 1151     (left_indexer, right_indexer) = self._get_join_indexers()
   1153     if self.right_index:
   1154         if len(self.left) > 0:

File ~\gain\Lib\site-packages\pandas\core\reshape\merge.py:1125, in _MergeOperation._get_join_indexers(self)
   1123 # make mypy happy
   1124 assert self.how != "asof"
-> 1125 return get_join_indexers(
   1126     self.left_join_keys, self.right_join_keys, sort=self.sort, how=self.how
   1127 )

File ~\gain\Lib\site-packages\pandas\core\reshape\merge.py:1759, in get_join_indexers(left_keys, right_keys, sort, how)
   1757     _, lidx, ridx = left.join(right, how=how, return_indexers=True, sort=sort)
   1758 else:
-> 1759     lidx, ridx = get_join_indexers_non_unique(
   1760         left._values, right._values, sort, how
   1761     )
   1763 if lidx is not None and is_range_indexer(lidx, len(left)):
   1764     lidx = None

File ~\gain\Lib\site-packages\pandas\core\reshape\merge.py:1795, in get_join_indexers_non_unique(left, right, sort, how)
   1793 lkey, rkey, count = _factorize_keys(left, right, sort=sort)
   1794 if how == "left":
-> 1795     lidx, ridx = libjoin.left_outer_join(lkey, rkey, count, sort=sort)
   1796 elif how == "right":
   1797     ridx, lidx = libjoin.left_outer_join(rkey, lkey, count, sort=sort)

File join.pyx:156, in pandas._libs.join.left_outer_join()

MemoryError: Unable to allocate 5.45 GiB for an array with shape (731048186,) and data type int64